unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.87k stars 716 forks source link

`TemplateBinding` with `AttachedProperty` fails #2259

Closed juliecantin closed 1 year ago

juliecantin commented 4 years ago

Current behavior

This binding works on UWP but not on iOS/Android: HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"

Expected behavior

TemplateBinding on an attached property works with this syntax.

How to reproduce it (as minimally and precisely as possible)

Clone this repo, checkout branch dev/juca/template-binding and launch the app On Windows, you can scroll to the right. On Android, iOS and WASM, you cannot scroll, because the properties we set in the style are ignored when the TemplateBinding fails.

Environment

Nuget Package:

Package Version(s): 1.45.0 and also 2.1.0-dev.90

Affected platform(s):

Visual Studio:

Relevant plugins:

Anything else we need to know?

MartinZikmund commented 3 years ago

Additional info from duplicate issue:

Some styles are set for attached properties, as follows:

<Style TargetType="primitives:TabViewListView">
        ...
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled" />
        <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Enabled" />
        <Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="False" />
        <Setter Property="ScrollViewer.VerticalScrollMode" Value="Disabled" />
        <Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="False" />
        <Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
        <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
        <Setter Property="ScrollViewer.BringIntoViewOnFocusChange" Value="True" />

This is then referenced in the template:

<ScrollViewer x:Name="ScrollViewer"
                            Grid.Column="1"
                            AutomationProperties.AccessibilityView="Raw"
                            BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}"
                            HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                            HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                            IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
                            IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
                            IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}"
                            IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
                            IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}"
                            TabNavigation="{TemplateBinding TabNavigation}"
                            VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                            VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                            ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}"
                            Style="{StaticResource TabScrollViewerStyle}">

This should work also when the attached property is set in code-behind:

ScrollViewer.SetHorizontalScrollMode(tabListView, Visible);

This is not currently supported in Uno.

MartinZikmund commented 1 year ago

Reopened for backport

MartinZikmund commented 1 year ago

Backported, done!