我想将参数从一个页面传递到另一个页面。 [英] I want to pass parameter from one page to another.
本文介绍了我想将参数从一个页面传递到另一个页面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在C#中有点新鲜并在项目中工作。
我在Xaml中有一个包含按钮的页面在点击它的时候会导航我到另一个页面。
我的要求是当我在第一页点击按钮导航到另一个页面时我需要一些价值在第二页,以便我找出点击了哪个按钮。
问候
Sunny
我尝试过:
i不知道如何做到这一点。我认为该参数iuse关键字
解决方案
检查了这一点:如何从一个WPF页面获取值另一个WPF页 [ ^ ]
感谢Buddy的工作。
当我从First页面传递值,将值重定向到另一个页面的构造函数时,我获取值并使用。
第一页
private void ABC(对象发送者,RoutedEventArgs e)
{
if(win2 == null)
{
win2 = new SecondPage(valuePassed);
win2.ShowDialog();
}
}
秒页面
字符串F;
public SecondPage(String FN)
{
InitializeComponent();
F = FN;
}
这里ValuePassed从传递 firstPage和SecondPage我在变量FN中收到它然后使用。
谢谢
问候
Hello all,
I am bit new in C# and working in a project.
I have one page in Xaml containing buttons in which when click on it will navigate me to another page.
My requirement is that when i navigate to another page on clicking the button in first page i need some value in second page so that i figure out that which button is clicked.
Regards
Sunny
What I have tried:
i dont know how to do this. i think iuse this keywords.
解决方案
Check this out: how to get values from one wpf page to another wpf page[^]
Thanks Buddy its works.
As i passed the value from First page which redirect the value to the constructor of another page their i fetch the value and use.
First Page
private void ABC(object sender, RoutedEventArgs e)
{
if (win2==null)
{
win2 = new SecondPage(valuePassed);
win2.ShowDialog();
}
}
Second Page
String F;
public SecondPage(String FN)
{
InitializeComponent();
F = FN;
}
Here "ValuePassed" is passed from "firstPage" and in "SecondPage" i received it in Variable "FN" and then used.
Thanks
Regards
这篇关于我想将参数从一个页面传递到另一个页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文