Evaluate ContentControl without rendering to screen

Posted by thedesertfox on Stack Overflow See other posts from Stack Overflow or by thedesertfox
Published on 2010-04-05T21:20:11Z Indexed on 2010/04/05 21:23 UTC
Read the original article Hit count: 294

Filed under:
|

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>();

© Stack Overflow or respective owner

Related posts about wpf-binding

Related posts about wpf