纠结中
在MainPage.xaml.cs中调用了自定义类中的方法showquery,把MainPage页面中的LayoutRoot传递过去,用于添加子元素bt(红色),bt的click事件bt_Click参数好像固定是(object sender, RoutedEventArgs e),不能把LayoutRoot传递过去.我想在bt_Click事件中引用LayoutRoot,这个该怎么办呢?
在jquery中,可以通过parent()这样的找到父容器,这里可以通过sender来找到LayoutRoot么???
或者用什么其它的方式??
public static void showquery(Canvas LayoutRoot)
{
Button bt = new Button();
bt.Name = "gyy1";
bt.Content = "查询";
bt.Click += new RoutedEventHandler(bt_Click);
LayoutRoot.Children.add(btnattribution) //添加子元素
}
static void bt_Click(object sender, RoutedEventArgs e)
{
//这里如何引用LayoutRoot
}