Adding Border to the pagehas navigationView, toggle button does not work in UWP application.

Ela 21 Reputation points
2021-10-12T21:31:54.913+00:00

Working on a UWP app that doesn't want a tittle bar, so the NavigationView will extend top to bottom.
Adding a border to the page that has NavigationView - toggle button does not work. So I added a grid and set it to Titlebar with height of 32 - doing so the toggle button works. But this adds a space for the titlebar of height 32(Which I dont want). So then I collapsed the Titlebar. NvaigationView toggle button works and there is no space between navview and border. Coz of this window dragging is not working. Any suggestions on how to approach this issue?
Below is my Code:

<Border BorderBrush="Red" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>

        <Grid x:Name="AppTitleBar" Background="Transparent"  Visibility="Collapsed"/>
        <NavigationView Grid.Row="1" Name="NaveView"  
                    CompactModeThresholdWidth="200"
                    ExpandedModeThresholdWidth="10000"
                    IsSettingsVisible="True" IsPaneToggleButtonVisible="True" />
    </Grid>
</Border>

Code Behind:
public MainPage()
{
this.InitializeComponent();
var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = true;
coreTitleBar.LayoutMetricsChanged += CoreTitleBar_LayoutMetricsChanged;
// Set XAML element as a draggable region.
Window.Current.SetTitleBar(AppTitleBar);
}

    private void CoreTitleBar_LayoutMetricsChanged(CoreApplicationViewTitleBar sender, object args)
    {
        AppTitleBar.Height = sender.Height;
    }
Universal Windows Platform (UWP)
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,851 Reputation points
    2021-10-13T02:30:40.313+00:00

    Hello, Welcome to Micorosoft Q&A,

    So then I collapsed the Titlebar. NvaigationView toggle button works and there is no space between navview and border. Coz of this window dragging is not working.

    It's by-design, please check document here. The draggable region you specify needs to be hit testable, and if you set the Grid Visibility="Collapsed" , it will not be hit testable. and this area will not draggable.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.