views:

18

answers:

1

Hy, Can someone tell me how can i find the page parent of an element in Silverlight 4. The element is in a page of a Project2 (is a userControl), and i want to find that page in the codeSource of the ControlElement. The code which i use now is this (this code is in control):

Project1.MainPage pageM = Application.Current.RootVisual as Project1.MainPage;
Page page = pageM.ContentFrame.Content as Page;
TabControl tabControl = page.FindName("tabControl") as TabControl;

But the problem is that i can-t add a reference to Project1 from Project2, because i have a reference to Project2. I need to find the parent because i want to add something in the tabControl from that page.

Here is how i use the control in Project1:

<usrctrl:Menu x:Name="Menu" VerticalAlignment="Top"HorizontalAlignment="Stretch" Margin="5,1,0,0">

Thanks.

A: 

No... Stop... Don't... Go back... Danger ahead...

Please find a better way. Try commanding, MVVM & Prism event-handling. Anything but directly linking otherwise unrelated parts of your application together.

Heck even shared objects that both pages can see (data store?) would be an improvement (although also not recommended for serious development).

Enough already
OK, thanks I think i will try to find another way for that.
tribanp