Search code examples
c#xamluwpwin-universal-apptabview

UWP Hide TabView Footer


I have TabView that basically looks like this:

    <controls:TabView
        x:Name="PlaylistTabView">
        <controls:TabView.ItemHeaderTemplate>
            <DataTemplate x:DataType="data:Playlist">
                // Something
            </DataTemplate>
        </controls:TabView.ItemHeaderTemplate>
        <controls:TabView.ItemTemplate>
            <DataTemplate x:DataType="data:Playlist">
                <local:HeaderedPlaylistControl IsPlaylist="True" Loaded="HeaderedPlaylistControl_Loaded" />
            </DataTemplate>
        </controls:TabView.ItemTemplate>

        <controls:TabView.TabStartHeader>
            // Something
        </controls:TabView.TabStartHeader>

        <controls:TabView.TabEndHeader>
            // Something
        </controls:TabView.TabEndHeader>

        <controls:TabView.Footer>
            <RelativePanel
                x:Name="PlaylistFooter"
                Height="{StaticResource PlaylistTabFooterHeight}"
                RenderTransformOrigin="0,0">
                <RelativePanel.RenderTransform>
                    <TranslateTransform />
                </RelativePanel.RenderTransform>
                <local:IconTextButton
                    x:Name="ShowAllPlaylistButton"
                    Padding="10,5"
                    IconTextMargin="0,0,10,0"
                    LabelPosition="Left"
                    RelativePanel.AlignRightWithPanel="True"
                    Style="{StaticResource PlaylistIconTextButtonStyle}"
                    ToolTipService.ToolTip="Show All Playlists">
                    <local:IconTextButton.Icon>
                        <FontIcon
                            x:Name="UpArrowIcon"
                            FontFamily="Segoe MDL2 Assets"
                            FontWeight="{x:Bind ShowAllPlaylistButton.FontWeight}"
                            Glyph="&#xE70E;"
                            RenderTransformOrigin=".5,.5">
                            <FontIcon.RenderTransform>
                                <RotateTransform />
                            </FontIcon.RenderTransform>
                        </FontIcon>
                    </local:IconTextButton.Icon>
                    <local:IconTextButton.Flyout>
                        <MenuFlyout Closed="ClosePlaylistsFlyout" Opening="OpenPlaylistsFlyout" />
                    </local:IconTextButton.Flyout>
                </local:IconTextButton>
                <local:IconTextButton
                    x:Name="SortByButton"
                    Padding="10,5"
                    HorizontalAlignment="Right"
                    Icon="Sort"
                    IconTextMargin="10,0,0,0"
                    Label="Sort By Title"
                    LabelPosition="Right"
                    RelativePanel.AlignLeftWithPanel="True"
                    Style="{StaticResource PlaylistIconTextButtonStyle}"
                    Tapped="SortByButton_Tapped"
                    ToolTipService.ToolTip="Sort Playlists" />
            </RelativePanel>
        </controls:TabView.Footer>
    </controls:TabView>

I have a local:HeaderedPlaylistControl in the ItemTemplate which is basically a ListView. I want to implement the effect that as you scroll down the footer will translate down and when you scroll up the footer will quickly show up.

I am able to implement such effect. However, I am only moving the PlaylistFooter not the TabView.Footer, meaning that the Footer lingers and leaves a blank space at the bottom as is shown in the picture below. How can I move the footer as well?

Hidden


Solution

  • I checked your code, I found you have implemented TranslateTransform for PlaylistFooter, if you just move the PlaylistFooter down not set Visibility as Collapsed, the footer will still display, So the better way is set Visibility as Collapsed.

    <VisualStateGroup x:Name="FooterVisibilityStates">
        <VisualState x:Name="FooterFadeIn">
            <Storyboard>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PlaylistFooter" Storyboard.TargetProperty="Opacity">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                    <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1" />
                </DoubleAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaylistFooter" Storyboard.TargetProperty="Visibility">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="Visibility" />
                </ObjectAnimationUsingKeyFrames>
    
            </Storyboard>
        </VisualState>
        <VisualState x:Name="FooterFadeOut">
            <Storyboard>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PlaylistFooter" Storyboard.TargetProperty="Opacity">
                    <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0" />
                </DoubleAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaylistFooter" Storyboard.TargetProperty="Visibility">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.4" Value="Collapsed" />
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaylistFooter" Storyboard.TargetProperty="IsHitTestVisible">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="False" />
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </VisualState>
    </VisualStateGroup>
    

    Update

    After discuss with Seaky Luo, we found a solution that set PlaylistFooter height as 0 when the list view scroll down. For more please refer the following code.

    <Storyboard x:Name="HideFooterAnimation">
            <DoubleAnimation
                Storyboard.TargetName="PlaylistFooter"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)"
                To="0"
                Duration="0:0:0.1" />
            <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="PlaylistFooter"
                Storyboard.TargetProperty="Height"
                Duration="0:0:0.1">
                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PlaylistTabFooterHeight}" />
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Name="ShowFooterAnimation">
            <DoubleAnimation
                Storyboard.TargetName="PlaylistFooter"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)"
                To="{StaticResource PlaylistTabFooterHeight}"
                Duration="0" />
            <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="PlaylistFooter"
                Storyboard.TargetProperty="Height"
                Duration="0">
                <DiscreteObjectKeyFrame KeyTime="0" Value="0" />
            </ObjectAnimationUsingKeyFrames>
    </Storyboard>