Silverlight parent form passed value to ChildWindow

Source: Internet
Author: User
Tags silverlight

On the internet to find a lot of columns, some do not understand, some too troublesome.

Now there are two ways to be simple and practical, to share to everyone!

First: Use the constructor to pass a value

1. Create a new constructor for the child page

1   PublicChildwindowtest (stringtexts)2         {3           4 InitializeComponent ();5             //the value passed by the parent class .6              This. Text1.Text =texts;7         }8 9 //texts is the value passed from the parent page.

2. Parent Page object that creates a child page

1 // you need to pass a value in the ChildWindow constructor 2 New Childwindowtest ("ChildWindow Usage: Parent page, sub-page mutual value ");

3, the sub-page constructor parameter texts is "ChildWindow Usage: Parent page, sub-page mutual value"

The second type:

1. Define a method on the sub-page

1  Public void UPDATETEXT (string2        {3             tbname.text = Str; 4         }

2. Create a child Page object on the parent page

1 New Childwindowtest ();

3. How to invoke a child page when the child page is facing the parent page:

1 childwindow.updatetext ("ChildWindow Usage: Parent page, sub-page mutual value ");

In the method UpdateText (string Str) of the child page, you can manipulate the passed value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.