[英]c# Moving data from one xaml to another xaml in UWP
It is a possibility to move data from one xaml to another xaml? 是否可以将数据从一个xaml移到另一个xaml?
On MainPage I have textbox where I can write numbers and button which add "5" and navigate to Page1, on Page1 I have textblock where I want to show result. 在MainPage上,我有一个文本框,可以在其中输入数字和按钮,这些数字和按钮添加“ 5”并导航到Page1,在Page1上,我有一个文本块,我想在其中显示结果。
eg MainPage 例如MainPage
textbox = 5, press button 文本框= 5,按下按钮
Page1 textblock = 10 Page1文字区块= 10
I couldn't find any information about UWP. 我找不到有关UWP的任何信息。
You can share data between pages by passing parameters. 您可以通过传递参数在页面之间共享数据。
var value = int.Parse(textbox.Text) + 5; // make sure you handle faulty input
Frame.Navigate(typeof(Page1), value);
and in Page1
, you can access that value with this override: 在
Page1
,您可以使用以下覆盖访问该值:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var value = (int)e.Parameter; // this should be 10
// ... do what you need with that value
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.