none
NavigationView takes up same amount of space when closed.

    Question

  • I have a NavigationView control that is on my MainPage and a databind for NavigationViewItems. When the navigationview control is closed (IsPaneOpen = False) I expect my UI to collapse and the content and controls to the right to move over to take the space which was taken by the NavigationView when it was open. But in my code, the pane is closed but it still takes the same amount of space. I tried binding the Grid.RowDefinition Width to the NavigationView control actualwidth but that didn't seem to work. Further testing showed that even when it's closed, the NavigationView control's width remains the same. So what am I missing here?

    Here's my XAML.

    <Grid x:Name="mainGrid" Background="{ThemeResource SystemControlAcrylicWindowBrush}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <RelativePanel>
                <NavigationView x:Name="navView" IsPaneOpen="True" IsSettingsVisible="False" Header="existing Workflows" Height="{Binding ElementName=mainGrid, Path=ActualHeight}" />
                <StackPanel x:Name="btnStartMoveOutWorkflow" RelativePanel.RightOf="navView" Orientation="Vertical" Margin="0,60,0,0">
                    <Button x:Name="btnStartNewPlan" Content="Start New Plan" Click="btnStartNewPlan_Click" />
                </StackPanel>
            </RelativePanel>
        </Grid>

    Thursday, March 8, 2018 4:41 PM

All replies

  • Hi Phillip.F,

    Welcome to the MSDN forum.

    Refer to your description, it seems your issue is about the UWP development. Since our forum is to discuss the VS IDE, I will help you move this thread to the appropriate forum for a better support, thank you for your understanding.

    Best regards,

    Sara


    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, March 9, 2018 1:57 AM
  • Sorry about that. I guess I missed the UWP forum in the list. I'll look harder next time!
    Friday, March 9, 2018 2:51 AM
  • Hi Phillip.F,

    Based on your words, you want your controls to change place depends on the pane of the NavigationView

    Have you tried to add your control in the content of the NavigationView. Like this:

        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    
                <NavigationView x:Name="navView" IsPaneOpen="True" IsSettingsVisible="True" Header="existing Workflows" >
                    <NavigationView.MenuItems>
                        <NavigationViewItem Icon="Play" Content="Menu Item1"  />
                       
                    </NavigationView.MenuItems>
                <Button x:Name="btnStartNewPlan" Content="Start New Plan" Click="btnStartNewPlan_Click" />
            </NavigationView>
    
      
        </Grid>

    It will auto adjust the place of the button.

    When the pane is open:

    When the pane is closed:

    For more information about NavigationView, please refer: Navigation view.


    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.

    Monday, March 12, 2018 6:50 AM
    Moderator