Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP NavigationView set IsPaneOpen false

Tags:

uwp

uwp-xaml

I Have a navigation view like this:

<NavigationView           
    MenuItemsSource="{Binding HamMneuItems}"
    IsPaneOpen="False"
    Margin="0,0,0,0" 
    Grid.Row="0"
    Grid.RowSpan="2"
    CompositeMode="SourceOver"            
    x:Name="nvSample"
    IsSettingsVisible="True" 
    IsTabStop="False"            
    Header="{Binding Titulo,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" SelectionChanged="NvSample_SelectionChanged">
    <Frame x:Name="ScenarioFrame"
        Margin="5,0,5,5"
        Grid.Column="0"
        Grid.Row="0"
        Grid.RowSpan="2"
        d:IsHidden="True"/>
</NavigationView>

The property IsPaneOpen is set to false, but it always show the pane opened, y tried setting IsPaneOpen to false at code behind in Page_Loaded event, at navigation view Loaded event with no results.

Now my question is how can I do to show NavigationView in compact mode first time it's showed ?.

or

Where to set IsPaneOpen to Hide pane at code behind ?

like image 333
Juan Pablo Gomez Avatar asked Dec 18 '22 23:12

Juan Pablo Gomez


1 Answers

In xaml setup a 'Loaded' event

<NavigationView 
    Loaded="nvSample_Loaded" 

In code behind nvSample_Loaded Event:

private void nvSample_Loaded(object sender, RoutedEventArgs e)
{
     nvSample.IsPaneOpen = false;
}
like image 134
Jerry Avatar answered Dec 28 '22 10:12

Jerry