我是一名正在开发uwp项目的初学者,我创建了一个' SplitViewRootControl'这是这样的:
<Grid>
<Image Source="ms-appx:///Assets/Background.jpg" Stretch="Fill"/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<SplitView x:Name="SplitViewRootControl" Grid.Row="1" DisplayMode="CompactInline" OpenPaneLength="150" CompactPaneLength="0" PaneBackground="Black" Opacity=".8">
<SplitView.Pane>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<RelativePanel>
<Image x:Name="userIcon" Source="ms-appx:///Assets/user.png" Width="35" RelativePanel.AlignLeftWithPanel="True" Margin="10,20,0,0"/>
<TextBlock x:Name="user" RelativePanel.RightOf="userIcon" RelativePanel.AlignVerticalCenterWith="userIcon" RelativePanel.AlignTopWith="userIcon" Text="User:" FontSize="13" Margin="5,18,0,0" Foreground="Ivory" />
<TextBlock x:Name="userName" RelativePanel.RightOf="userIcon" RelativePanel.Below="user" Text="Chen Yinjue" FontSize="13" Margin="5,0,0,0" Foreground="Ivory" />
</RelativePanel>
<GridView Grid.Row="1" HorizontalAlignment="Center" Margin="0,50,0,0" ScrollViewer.VerticalScrollBarVisibility="Auto">
<StackPanel>
<Image Source="ms-appx:///Assets/messenger.png" Width="70" />
<TextBlock Text="Messenger" FontSize="18" Foreground="Ivory" HorizontalAlignment="Center" Margin="0,0,0,50"/>
<Image Source="ms-appx:///Assets/warning.png" Width="70" />
<TextBlock Text="Alert" FontSize="18" Foreground="Ivory" HorizontalAlignment="Center" Margin="0,0,0,50"/>
<Image Source="ms-appx:///Assets/cctv.png" Width="70" />
<TextBlock Text="Camera Setup" FontSize="18" Foreground="Ivory" HorizontalAlignment="Center" Margin="0,0,0,50"/>
<Image Source="ms-appx:///Assets/more.png" Width="70" />
<TextBlock Text="More" FontSize="18" Foreground="Ivory" HorizontalAlignment="Center" />
</StackPanel>
</GridView>
<Button Grid.Row="2"
Style="{StaticResource ResourceKey=appButtonStyle}"
HorizontalAlignment="Center"
Content="Log Out"
FontSize="20"
Foreground="White"
Background="#dd514c"/>
</Grid>
</SplitView.Pane>
<SplitView.Content>
<Grid>
<Frame x:Name="rootFrame"/>
<Button Name="HamburgerBtn"
Style="{StaticResource ResourceKey=appButtonStyle}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Background="Black"
Opacity=".4"
Click="HamburgerBtn_Click">
<Image Source="ms-appx:///Assets/paneBtn.png" Height="300" Width="20"/>
</Button>
</Grid>
</SplitView.Content>
</SplitView>
</Grid>
</Grid>
我设法让应用中的所有网页都可以访问这个&#39; splitview&#39;通过覆盖&#39; OnLaunched&#39;在app.xaml.cs中:
var rootControl = Window.Current.Content as SplitViewRoot;
if (rootControl == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootControl = new SplitViewRoot();
rootControl.RootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootControl;
}
if (rootControl.RootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootControl.RootFrame.Navigate(typeof(LoginPage), e.Arguments);
}
Window.Current.Activate();
问题是有一个&#39;登录页面&#39;在应用程序中它不应该有这个&splitview&#39;在它的页面。所以基本上我希望我的所有页面都可以访问&#39; splitview&#39;除了登录页面&#39;。谁知道怎么做?任何建议表示赞赏!