I have searched the net for a way to access an object/property within a UserControl. I have a Page object in my view in wich i load a usercontrol:
<UserControl:RichTextEditorControl Height="350" />
How do i access an object/property which resides in the viewmodel of my view from my usercontrol? To put my problem in practice: i have a list of items that is displayed in my view, and when i have selected an item, i load the usercontrol. I then want my usercontrol to do “stuff” to the selected item. How can i do this?
Thanx!
You can have the selected item be either a Dependency Property on your UserControl, or just be it’s DataContext. You could then just setup the UserControl using binding:
If your list box binds to that same
TheSelectedObjectProperty, the UserControl will see the selected item when you change items in the list box automatically.