views:

31

answers:

1

Hi guys,

I have a DataObject and a DataTemplate that has the DataType=x:Type DataObject. I have a ContentControl which has as Content the DataObject. On OnContentChanged() of that ContentControl I need to access smtg from the DataTemplate of the new Conten which is a DataObject.

How can I do this?

Inverse, If I have a UIObject and I need to obtain the data behind I get it trough DataContext, but I don't know how to get it this way.

Please help, Daniel

+1  A: 

Daniell,

I think you are going wrong way here. Do what you need to do inside DataObject, then use triggers, attached behaviors, styles and whatsnot inside DataTemplate, to reflect proper state of the DataObject.

The less advisable solution would be VisualTreeHelper, but using it you are asking for a trouble.

Anvaka
I need the UIObject to pass it as a parameter to a method in code behind. This method deals with a lot of changes there. I know what you say is true, but is there any way to obtain the object as requested ? :(
daniell
VisualTreeHelper is one option. Another may be attached properties.
Anvaka