8,735
社区成员
发帖
与我相关
我的任务
分享
private void Button_Click(object sender, RoutedEventArgs e)
{
mainFrame.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
}
<UserControl x:Class="NavigationTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White" Loaded="LayoutRoot_Loaded">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Margin="10" Padding="10" BorderBrush="DarkOrange"
BorderThickness="2" CornerRadius="4">
<navigation:Frame x:Name="mainFrame"></navigation:Frame>
</Border>
<Button Grid.Row="1" Margin="5" Padding="5" HorizontalAlignment="Center"
Content="Go to Page1" Click="Button_Click"></Button>
</Grid>
</UserControl>