daniell
daniell

Reputation: 222

How to access the DataTemplate of a DataObject that has the DataTemplate with DataType assigned?

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

Upvotes: 1

Views: 144

Answers (1)

Anvaka
Anvaka

Reputation: 15823

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.

Upvotes: 1

Related Questions