我在我的应用程序中打开了一个新页面。
XAML
<MenuItem Header="Admin" IsTabStop="False">
<MenuItem x:Name="mi_ManageUsers" Header="Manage Users" Click="mi_ManageUsers_Click"/>
</MenuItem>
C#
private void mi_ManageUsers_Click(object sender, RoutedEventArgs e)
{
ManageUsers newPage = new ManageUsers();
this.Content = newPage;
}
现在我的新页面中有一个按钮
XAML
<Page x:Class="Billing.ManageUsers"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="ManageUsers">
<Grid>
<Button x:Name="btnClose" Content="Close" HorizontalAlignment="Left" Margin="185,219,0,0" VerticalAlignment="Top" Width="75" Click="btnClose_Click"/>
</Grid>
</Page>
C#
private void btnClose_Click(object sender, RoutedEventArgs e)
{
//OnReturn(new ReturnEventArgs<string>(this.dataItem1TextBox.Text));
this.NavigationService.GoBack();
}
但是代码不起作用。我需要关闭这个新页面或通过单击按钮返回上一个窗口