2 个不同页面之间的 MVVM 传输 [英] MVVM transfer between 2 different pages
问题描述
我有 MainPaqe.cs
(MainPaqe.xaml
) 和 Periodic_Request.cs
(Periodic_Request.xaml
),此外,Periodic_Request.xaml
有名为 TxtBlock_numRequest
的 TextBox
和名为 CmbBox_lvlPriority
的 Combobox
代码> 可能有 3 个选项.
I have MainPaqe.cs
(MainPaqe.xaml
) and Periodic_Request.cs
(Periodic_Request.xaml
), in addition, Periodic_Request.xaml
has TextBox
with name TxtBlock_numRequest
and Combobox
with name CmbBox_lvlPriority
with possible 3 options.
问题是如何从 MainPaqe.cs
中的 TextBox
和 Combobox
获取用户书写的数字或字符串.我需要在按下 button
后获取所有这些信息.
The problem is how get user written numbers or strings from TextBox
and Combobox
in the MainPaqe.cs
. I need to get all this information after pressing button
.
我完全无法理解如何编写它并使用该模式,所以这就是为什么我需要实际代码
I completely can`t understand how to write it and use that pattern, so this why I need actual code
推荐答案
您可以尝试在 QueryString 中传递数据吗?查看此链接 样品
You can try passing the data in a QueryString? Check out this link for samples
private void button_Click(object sender, RoutedEventArgs e)
{
string uri = String.Format("/Periodic_Request.xaml?numRequest={0}", TxtBlock_numRequest.Text);
NavigationService.Navigate(new Uri(uri, UriKind.Relative));
}
这篇关于2 个不同页面之间的 MVVM 传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!