How to change ListBox DataTemplate in WPF based on CheckBox?

Your data template is a StaticResource defined in app. Xaml, you are trying to do an element name binding to the element IssueListBox which doesn't exist in the same scope. Even then what you are trying to do is this.

Listbox has a data template DT, inside DT you are trying to reach back to the List box and set its DataTemplate to another one (not DT).

Your data template is a StaticResource defined in app. Xaml, you are trying to do an element name binding to the element IssueListBox which doesn't exist in the same scope. Even then what you are trying to do is this.

Listbox has a data template DT, inside DT you are trying to reach back to the List box and set its DataTemplate to another one (not DT). Why don't you combine the templates, set the visibility on the details to collapsed and trigger the visibility based on your property. Then you don't have to reference the list box at all and the template stays the same, it just changes internally when you want to see the details.

1 That did the trick although I am still left wondering how I would handle it if I needed two templates. Life was so much easier when I just added an event handler to the checked. Changed event but I am trying to develop better habits as I am learning adn make things as MVVMish as I can while learnign xaml.

– Mike B Jan 13 '10 at 14:53 you can use a data template selector, but that is to decide between data templates when they are added, not when properties change. – Aran Mulholland Jan 14 '10 at 0:09.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions