简体   繁体   中英

Silverlight ChildWindow - Update label with textbox

I have very simple code in C# to present MessageBox:

MessageBox.Show("Hello Action!");

Now I need to do the following: to replace the MessageBox by a Silverlight ChildWindow element, Add a label, a button and a textbox and after that Pressing the button updates the label content with the textbox content.

How to do it? I did not find some example on the Net.

My full code is this:

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!");
        }
    }
}

Add the Textbox and the Button to the childwindow in silverlight.

And you can pass the content as a parameter while opening and update it like below.

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

and change the constructor of Childwindow as follows,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM