单击Silverlight源按钮需要帮助. [英] Need help with silverlight source button clicked.
本文介绍了单击Silverlight源按钮需要帮助.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个Silverlight应用程序,我有两个窗口,第一个窗口是父窗口,其中有几个按钮,现在其中两个打开了一个窗口供我搜索,现在我需要的是如何从中知道单击按钮后的第二个窗口,我如何找出按下了哪个按钮?
在此先谢谢您,
Ram.
Hi everyone,
I have a silverlight app and i have two windows, first window is the parent and i have a few buttons in it, now two of them open the same window where i do a search, now for what i need is how can i know from the second window after the button click, how do i find out which button was pressed?
Thanks in advanced,
Ram.
推荐答案
您只需为第二个窗口添加构造函数,即可在其中传递参数以标识单击的按钮,它可以是一个按钮.属性,甚至整个按钮对象(但这不是有效的方法.
You can simply add the constructor for second window, in which you''ll pass the parameter to identify clicked button, it could be a button.Tag property, or even the whole button object (but it would be not efficient way.
private Button_Click(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
if(button!=null)
{
Window2 window = new Window2(button.Tag);
}
else
{
Window2 window = new Window2();
}
}
这篇关于单击Silverlight源按钮需要帮助.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文