PullToRefreshListView icon indicating copy to clipboard operation
PullToRefreshListView copied to clipboard

ScrollIntoView no longer works

Open crea7or opened this issue 9 years ago • 8 comments

ScrollIntoView of ListView no longer works with this control.

crea7or avatar Apr 27 '16 23:04 crea7or

`<Style TargetType="UIElements:ExtendedListView">
            <Setter Property="IsTabStop"
                Value="False" />
            <Setter Property="TabNavigation"
                Value="Once" />
            <Setter Property="IsSwipeEnabled"
                Value="True" />
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
                Value="Disabled" />
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility"
                Value="Auto" />
            <Setter Property="ScrollViewer.HorizontalScrollMode"
                Value="Disabled" />
            <Setter Property="ScrollViewer.IsHorizontalRailEnabled"
                Value="False" />
            <Setter Property="ScrollViewer.VerticalScrollMode"
                Value="Enabled" />
            <Setter Property="ScrollViewer.IsVerticalRailEnabled"
                Value="True" />
            <Setter Property="ScrollViewer.ZoomMode"
                Value="Disabled" />
            <Setter Property="ScrollViewer.IsDeferredScrollingEnabled"
                Value="False" />
            <Setter Property="ScrollViewer.BringIntoViewOnFocusChange"
                Value="True" />
            <Setter Property="VerticalAlignment"
                Value="Stretch" />
            <Setter Property="HorizontalAlignment"
                Value="Stretch" />
            <Setter Property="Foreground"
                Value="Black" />
            <Setter Property="ItemContainerTransitions">
                <Setter.Value>
                    <TransitionCollection>
                        <AddDeleteThemeTransition />
                        <ContentThemeTransition />
                        <ReorderThemeTransition />
                        <EntranceThemeTransition IsStaggeringEnabled="False" />
                    </TransitionCollection>
                </Setter.Value>
            </Setter>
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <ItemsStackPanel Orientation="Vertical" />
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="UIElements:ExtendedListView">
                        <Grid x:Name="ContainerGrid">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="VisualStateGroup">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.2"
                                                      To="ReadyToRefresh" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="ReadyToRefresh">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                       Storyboard.TargetName="TextPull">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Collapsed</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                       Storyboard.TargetName="TextRefresh">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimation Duration="0"
                                                         To="0.5"
                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)"
                                                         Storyboard.TargetName="Arrow"
                                                         d:IsOptimized="True" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">
                                <ScrollViewer
                                          x:Name="ScrollViewer"
                                          TabNavigation="{TemplateBinding TabNavigation}"
                                          HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                                          HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                                          IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}"
                                          VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                                          VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                                          IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}"
                                          IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
                                          IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
                                          ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}"
                                          IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
                                          BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}"
                                          AutomationProperties.AccessibilityView="Raw">

                                    <ItemsPresenter
                                                    Footer="{TemplateBinding Footer}"
                                                    FooterTemplate="{TemplateBinding FooterTemplate}"
                                                    FooterTransitions="{TemplateBinding FooterTransitions}"
                                                    Padding="{TemplateBinding Padding}">
                                        <ItemsPresenter.Header>
                                            <Border Height="{TemplateBinding RefreshHeaderHeight}"
                                            x:Name="PullToRefreshIndicator"
                                            Background="Transparent">
                                                <Grid HorizontalAlignment="Center">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="auto" />
                                                        <ColumnDefinition Width="auto" />
                                                    </Grid.ColumnDefinitions>
                                                    <Grid Width="40">
                                                        <Viewbox x:Name="Arrow"
                                                         Height="15"
                                                         VerticalAlignment="Top"
                                                         Margin="0,4,0,0"
                                                         RenderTransformOrigin="0.5,0.5">
                                                            <Viewbox.RenderTransform>
                                                                <CompositeTransform Rotation="180" />
                                                            </Viewbox.RenderTransform>
                                                            <Path Width="12"
                                                          Height="13"
                                                          Stretch="Fill"
                                                          Fill="{TemplateBinding ArrowColor}"
                                                          Data="M 20.4289,10.4376L 25,15.0087L 23.571,16.4376L 20.0291,12.8957L 20.0291,21.9999L 18.0083,21.9999L 18.0083,12.8583L 14.4289,16.4377L 13,15.0087L 17.5624,10.429L 19.0087,9" />
                                                        </Viewbox>
                                                    </Grid>
                                                    <TextBlock Grid.Column="1"
                                                       Foreground="{TemplateBinding Foreground}"
                                                       FontSize="20"
                                                       x:Name="TextPull"
                                                       Text="{TemplateBinding PullText}" />
                                                    <TextBlock Foreground="{TemplateBinding Foreground}"
                                                       FontSize="20"
                                                       x:Name="TextRefresh"
                                                       Visibility="Collapsed"
                                                       Text="{TemplateBinding RefreshText}"
                                                       Grid.Column="1" />
                                                </Grid>
                                            </Border>
                                        </ItemsPresenter.Header>
                                    </ItemsPresenter>
                                </ScrollViewer>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>`

depyronick avatar May 05 '16 11:05 depyronick

Very good! However, additional controls(textblocks and an arrow) are not accessible for animation.

crea7or avatar May 05 '16 16:05 crea7or

Why? In my case it works as expected.

depyronick avatar May 05 '16 16:05 depyronick

Due to some reason, VisualStateManager can't access the controls inside ItemsPresenter.Header. Did you changed the way how you call for changes in VisualStateManager?

WinRT information: Cannot resolve TargetProperty (UIElement.RenderTransform)(CompositeTransform.Rotation) on specified object. (it's an arrow viewbox. my project is wp 8.1 runtime).

crea7or avatar May 05 '16 16:05 crea7or

Did you update TargetType property to your own usage?

depyronick avatar May 05 '16 18:05 depyronick

Of course. I tried the manual resolution of these controls by name and it works well. Very strange... Viewbox arrowBox = ( Viewbox )GetTemplateChild( "Arrow" ) as Viewbox;

crea7or avatar May 05 '16 18:05 crea7or

It may be a 8.1 specific error. I am currently developing a WM10 app. If you could, please share the code. Someone else may looking for the same issue in the future.

depyronick avatar May 05 '16 18:05 depyronick

Sure, but I'll try to ask on stackoverflow first.

crea7or avatar May 05 '16 18:05 crea7or