Access Elements inside a DataTemplate... How to for more than 1 DataTemplate?

Posted by GaaTY on Stack Overflow See other posts from Stack Overflow or by GaaTY
Published on 2010-06-12T08:17:08Z Indexed on 2010/06/12 8:23 UTC
Read the original article Hit count: 354

Filed under:
|
|
|

I've got 2 DataTemplates defined for a Listbox Control. 1 Template is for the UnSelected State and the other one is for the Selected State(showing more detail than the UnSelected State).

I followed the example here:

http://blogs.msdn.com/b/wpfsdk/archive/2007/04/16/how-do-i-programmatically-interact-with-template-generated-elements-part-ii.aspx

about how to access the Elements inside the DataTemplates from Code behind.

I get it right, but it only finds and returns an element of the UnSelected DataTemplate. But when i search for an element in the Selected DataTemplate i get a NullReferenceException.

What could i be doing wrong?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about vb.net