Evaluate ContentControl without rendering to screen
- by thedesertfox
I have a datagrid and I'm writing a method to search through it to find some text. Practically all of my columns use a DataTemplateSelector, so in my search, I need to be able to take a DataTemplate, apply it to a ContentControl, and then find a TextBlock to get the text to see if it matches my search criteria. I'm trying the following but it's not seeming to produce any results. I also tried a FindName("layoutRoot" control) but that came back as null as well.
var control = new ContentControl();
control.ContentTemplate = dataTemplate;
control.Content = item;
var txtBox = control.FindChildren<TextBlock>();