DataTemplate defautl visibility for ContentControls
Posted
by bitbonk
on Stack Overflow
See other posts from Stack Overflow
or by bitbonk
Published on 2010-05-03T14:56:30Z
Indexed on
2010/05/03
19:48 UTC
Read the original article
Hit count: 357
In my MVVM based WPF application I have a lot of different ViewModel types that dynamically loaded into ContentControls or ContentPresenters. Therefor I need to explictly set what DataTemplate is to be used in XAML:
<ContentControl Content={Binding SomePropertyOfTypeViewModel} ContentTemplate={StaticResource someTemplate} />
Now my problem is that the content control is displaying the UI of someTemplate
even if the ContentControl is bound to nothing (i.e ViewModel.SomePropertyOfTypeViewModel is null)
Is there a quick and easy way to make all ContentControls display nothing if they are currently bound to nothing? When I use implicit DataTemplates everything works as expected. Unfortunately I can't use this mechanism here.
© Stack Overflow or respective owner