Silverlight ChildWindow-使用文本框更新标签

本文关键字:更新 标签 文本 ChildWindow- Silverlight | 更新日期: 2023-09-27 18:29:44

我在C#中有一个非常简单的代码来呈现MessageBox:

MessageBox.Show("Hello Action!");

现在我需要做以下操作:用Silverlight ChildWindow元素替换MessageBox,添加一个标签、一个按钮和一个文本框,然后按下按钮用文本框内容更新标签内容。

怎么做?我没有在网上找到一些例子。

我的完整代码是:

namespace DevTrainingSilverlight2
{
    public class HelloAction : W6Action
    {
        public override void Initialize(W6ActionConfigSection configuration, UIElement containingControl, UIElement associatedControl)
        {
            base.Initialize(configuration, containingControl, associatedControl);
        }
        public override void UpdateState(System.Collections.IList selectedObjectsInFocus)
        {
            base.UpdateState(selectedObjectsInFocus);
        }
        public override void Invoke(System.Collections.IList selectedObjectsInFocus)
        {
            base.Invoke(selectedObjectsInFocus);
            MessageBox.Show("Hello Action!");
        }
    }
}

Silverlight ChildWindow-使用文本框更新标签

在silverlight中将Textbox和Button添加到子窗口。

您可以在打开时将内容作为参数传递,并按如下所示进行更新。

 ChildWindowControl childControl = new ChildWindowControl(content);
 childControl.Show();

并更改Childwindow的构造函数如下,

public ChildWindowControl(string name)
 {
   InitializeComponent();
   this.lblValue = name;
 }