从Silverlight中的弹出控件传递值 [英] Pass value from popup control in silverlight

查看:51
本文介绍了从Silverlight中的弹出控件传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Silverlight中将数据从弹出的用户控件转移到MainPage.


我正在MainPage.xaml.cs文件中的下面代码中显示popuu UserControl,因此需要在Silverlight中将值从popupcontrol传递到主页.

i need to tranfer the data from the popup usercontrol to MainPage in silverlight.


I am using in the folloing code in MainPage.xaml.cs file to show the popuu UserControl so i need to pass the value from popupcontrol to the mainpage in silverlight.

private void Button_Click(object sender, RoutedEventArgs e)
{
    Popup p = new Popup();
    p.Child = new ChildUserControl();

    // Set where the popup will show up on the screen. 
    p.VerticalOffset = 100;
    p.HorizontalOffset = 400;

    // Open the popup. 
    p.IsOpen = true;
}



提前谢谢.



Thanks in advance.

推荐答案

首先,为什么当Popup很明显是自产对象时,为什么要从该对象之外的另一个对象中创建ChildUserControl?唯一应该这样做的是,如果您没有父对象的源代码.

其次,您何时希望MainPage知道ChildUserControl中的数据?

第三,使用.Net中的事件机制,让MainPage订阅Popup对象内部的事件.



编辑==================

为什么这次投票是1?我给你一个答案.



First, WHY are you creating the ChildUserControl in another object from outside that object, when it''s obvious that the Popup is a homegrown object? The only time you should do that is if you don''t have the sopource code to the parent object.

Second, when do you want MainPage to know about the data in ChildUserControl?

Third, use the event mechanism in .Net to let MainPage subscribe to events inside the Popup object.



EDIT ==================

Why was this vote a 1? I gave you an answer.




这篇关于从Silverlight中的弹出控件传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆