The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
1903 ExtendViewIntoTitleBar RRS feed

  • Question

  • CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; doesn't work.

    When SDk version is 1809, it is normal, Then I update SDK version to 1903, it not work.

    And if I down to 1809 or 1803, it is work. So I think it is a bug in 1903 SDK.

    How to fix this? Thanks

    Wednesday, June 26, 2019 1:16 AM

Answers

  • Hi,

    Yes, I reproduced this with NavigationView. But this behavior is expected in Build 1903. I checked the template style of the NavigationView for 1903 and 1809. They are different. There is a new part called "ContentTopPadding" in the 1903's NavigationView and it's the reason that causes the different behaviors. So that's not a problem. 

    If you wants to get the old style like 1809, you could just comment the part of ContentTopPadding control (actually it's a grid). Like this:

            <Style x:Key="NavigationViewStyle1" TargetType="NavigationView">
                <Setter Property="PaneToggleButtonStyle" Value="{StaticResource PaneToggleButtonStyle}"/>
                                ......so many style code here......
                                        <Grid x:Name="ContentGrid">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <!--<RowDefinition Height="Auto"/>-->
                                                <RowDefinition Height="*"/>
                                            </Grid.RowDefinitions>
                                            <!--<Grid x:Name="ContentTopPadding" Height="{Binding TemplateSettings.TopPadding, RelativeSource={RelativeSource Mode=TemplatedParent}}" Visibility="{Binding TemplateSettings.LeftPaneVisibility, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>-->
                                            <ContentControl x:Name="HeaderContent" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" HorizontalContentAlignment="Stretch" IsTabStop="False" MinHeight="{StaticResource PaneToggleButtonHeight}" Grid.Row="0" Style="{StaticResource NavigationViewTitleHeaderContentControlTextStyle}" VerticalContentAlignment="Stretch"/>
                                            <ContentPresenter Content="{TemplateBinding Content}" AutomationProperties.LandmarkType="Main" Grid.Row="1"/>
                                        </Grid>
                                    </SplitView>
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    You could open the Document Outline window in your VS, then find the NavigationView control and create a copy for the template.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, June 26, 2019 6:58 AM
    Moderator

All replies

  • Hi,

    Well, could you be more specific about this problem? I made a simple test for this. I created a blank app just with two line of the code:

     var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
                coreTitleBar.ExtendViewIntoTitleBar = true;

    Then I run the app to check the behavior you said but the result shows it work correctly. Do you have specific steps to reproduce the problem?

    Like this:

    and this:

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, June 26, 2019 2:26 AM
    Moderator
  • Thank first.

    I use the NavigationView in page. so I think it is about NavigationView.

    can you help me to try NavigationView? Thanks a lot.

    Wednesday, June 26, 2019 2:56 AM
  • Ok, I tried it. It is NavigationView's issue.

    In xaml:

    <Page
        x:Class="App1.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:App1"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Background="Black">
    
        <Grid>
            <NavigationView 
                Background="Red" Header="asdasd">
                <Grid  >
                    
                    <CommandBar 
                                HorizontalAlignment="Right"
                                VerticalAlignment="Top"
                                DefaultLabelPosition="Right"
                                >
                        <AppBarButton  Icon="Up"/>
                        <AppBarButton  Icon="Shuffle"/>
                        
                    </CommandBar>
                </Grid>
            </NavigationView>
    
        </Grid>
    </Page>
    

    in App.xaml.cs:

    protected override void OnLaunched(LaunchActivatedEventArgs e)
            {
                Frame rootFrame = Window.Current.Content as Frame;
    
                var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
                coreTitleBar.ExtendViewIntoTitleBar = true;

    Now run it, In 1809 version, Header extend to titlebar, like this image:

    But in 1903, same code, same layout, just SDK version changed, header not into titlebar, and command bar go down too:

    So I think it is the NavigationView's bug.

    Wednesday, June 26, 2019 3:25 AM
  • Hi,

    Yes, I reproduced this with NavigationView. But this behavior is expected in Build 1903. I checked the template style of the NavigationView for 1903 and 1809. They are different. There is a new part called "ContentTopPadding" in the 1903's NavigationView and it's the reason that causes the different behaviors. So that's not a problem. 

    If you wants to get the old style like 1809, you could just comment the part of ContentTopPadding control (actually it's a grid). Like this:

            <Style x:Key="NavigationViewStyle1" TargetType="NavigationView">
                <Setter Property="PaneToggleButtonStyle" Value="{StaticResource PaneToggleButtonStyle}"/>
                                ......so many style code here......
                                        <Grid x:Name="ContentGrid">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <!--<RowDefinition Height="Auto"/>-->
                                                <RowDefinition Height="*"/>
                                            </Grid.RowDefinitions>
                                            <!--<Grid x:Name="ContentTopPadding" Height="{Binding TemplateSettings.TopPadding, RelativeSource={RelativeSource Mode=TemplatedParent}}" Visibility="{Binding TemplateSettings.LeftPaneVisibility, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>-->
                                            <ContentControl x:Name="HeaderContent" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" HorizontalContentAlignment="Stretch" IsTabStop="False" MinHeight="{StaticResource PaneToggleButtonHeight}" Grid.Row="0" Style="{StaticResource NavigationViewTitleHeaderContentControlTextStyle}" VerticalContentAlignment="Stretch"/>
                                            <ContentPresenter Content="{TemplateBinding Content}" AutomationProperties.LandmarkType="Main" Grid.Row="1"/>
                                        </Grid>
                                    </SplitView>
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    You could open the Document Outline window in your VS, then find the NavigationView control and create a copy for the template.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, June 26, 2019 6:58 AM
    Moderator
  • Thanks a lot! It is work on 1903!

    But it have a new problem. The new NavigationViewStyle use some new ThemeResource that only can find in 1903.

    I set ThemeResource, it will crash in 1809 and 1803, like this error:

    Cannot find a Resource with the Name/Key NavigationViewSettingsItemStyleWhenOnTopPane

    So, how to solve this? I have no idea.

    Friday, June 28, 2019 4:31 AM
  • Hi,

    One way is to use controls from Windows UI Library, it will keep the controls in the latest version.

    Another way is that you need to defined the resources yourself in the page resources. For example, it crashes for NavigationViewSettingsItemStyleWhenOnTopPane, then you could find it in generic.xaml. Copy the resource and put in it the page resources so that your style could refer it.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 28, 2019 7:30 AM
    Moderator
  • I can't achieve compatibility through the Windows UI Library. It may be that my operation was wrong.

    I decided to release the version with the new features and give up support for the 1809 and below versions.

    Although this is awkward, it also solved my doubts. thank you for your help.

    Monday, July 1, 2019 1:32 AM