Click here to Skip to main content
15,885,998 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My question is: How can we access the controls of one silverlight xaml page from another

Scenario: I have a xaml page A. One button on Page A opens up a child window, which has a listbox full of options. When a user makes the selections and hits OK on the child window, a stackpanel on Page A gets updated. e.g. Say the child window listbox has 10 options. When the user selects 5 out of 10 options, the stackpanel ( inside datatemeplate of a listbox) on Page A shows 5 rows. If the user selects all 10 options, the stackpanel shows 10 rows of corresponding data on Page A and likewise.

Question: How can we access the stackpanel of Page A from the code behind of the child window.

so far, I think the following code works:

PageA control = (PageA)Application.Current.RootVisual;

control.stackPanel2.Children.Add(new Item());

But the above code works only if PageA is the MainPage or the start up file on App.xaml.cs. But in my case, PageA is not the MainPage or startup file. So how can we do it?
Posted
Comments
lewax00 16-May-13 16:14pm    
You're probably better off just making the child window part of the Silverlight application instead. I'm not sure how feasible it is to have them communicate directly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900