C# 如何将类数据重定向到xaml页面?

C# 如何将类数据重定向到xaml页面?,c#,.net,sqlite,xaml,uwp,C#,.net,Sqlite,Xaml,Uwp,我在将数据从类传输到xaml页面时遇到问题,在我的控制台中,数据显示在类中,但它不会传递到UWP中的xaml页面 var commonCheckValues = new CommonCheckValues(); if (!Common.GetCommonCheckVars(commonCheckValues)) return; var data = new PrintableReceiptData { TerminalName = c

我在将数据从类传输到
xaml
页面时遇到问题,在我的控制台中,数据显示在类中,但它不会传递到
UWP中的
xaml
页面

var commonCheckValues = new CommonCheckValues();
     if (!Common.GetCommonCheckVars(commonCheckValues))
         return;
var data = new PrintableReceiptData
       {
          TerminalName = commonCheckValues.Session.TerminalName,
          TableNumber = commonCheckValues.Order.Model.TableName,
         };

Frame frame = new Frame();
      frame.Navigate(typeof(demoProject.Scenario1Basic), data);
      Window.Current.Content = frame;
      Window.Current.Activate();
所以,它将数据显示到数据变量中,但当我尝试作为参数传递时,它不会在
Scenario1Basic
页面上接收值

如有任何建议,我们将不胜感激

如何将类数据重定向到xaml页面

当使用参数导航时,可以在目标页面
OnNavigatedTo
方法中获取参数,如下所示

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    var parameter = e.Parameter;
}
您还可以使用基于发布-订阅模型的create-base重定向数据

Page1->Page2

MessagingCenter.Subscribe<Page1, string>(this, "Tag", async (s, arg) =>
{
   await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
        textblock.Text = arg;
    });

});
Page2需要订阅Page1类

第2页

MessagingCenter.Subscribe<Page1, string>(this, "Tag", async (s, arg) =>
{
   await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
        textblock.Text = arg;
    });

});
MessagingCenter.Subscribe(此“标记”,异步,arg)=>
{
等待这个.Dispatcher.RunAsync(corespatcherpriority.Normal,()=>
{
textblock.Text=arg;
});
});
第1页

MessagingCenter.Send<Page1, string>(this, "Tag", "string parameter");
MessagingCenter.Send(此“标记”、“字符串参数”);

您在
OnNavigatedTo
覆盖方法中获取数据了吗?我在OnNavigatedTo方法中没有获取任何数据。受保护覆盖void OnNavigatedTo(NavigationEventArgs e){//我需要这里的数据,但我无法获取它}NavigationEventArgs参数字段中是否有数据?没有,但我需要此方法中的数据??