WPF导航到其他页面

时间:2016-01-15 22:06:52

标签: c# wpf xaml

我想在页面之间导航

IIF(ISNULL(EXT_INVOICED_QTY), 
DECODE(EXT_NET_AMOUNT, IIF(ISNULL(EXT_NET_AMOUNT),0,EXT_NET_AMOUNT) =0, EXT_INVOICED_QTY, -1),
EXT_INVOICED_QTY)

GetNavigationService返回null

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void RouteItems(object sender, RoutedEventArgs e)
    {
        NavigationService nav = NavigationService.GetNavigationService(this);
        nav.Navigate(new ItemsPage());
    }
}

我不想使用其他方法(更改内容)。

修改

this.NavigationService未定义

1 个答案:

答案 0 :(得分:-1)

您需要先向您的Xaml添加Frame

<Grid >
      <Grid.RowDefinitions>
          <RowDefinition Height="*"/>
          <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
   <Frame x:Name="MainFrame"></Frame>
    <Button Content="Go" Click="RouteItems" Grid.Row="1"/>

</Grid>

然后在添加xaml页面后,使用MainFrame进行导航:

 private void RouteItems(object sender, RoutedEventArgs e)
    {
        MainFrame.NavigationService.Navigate(new Uri("Page1.xaml", UriKind.RelativeOrAbsolute));
    }