<UserControl .....>
<DataTemplate DataType="{x:Type vm:AViewModel}">
<vw:AView />
</DataTemplate>
<DataTemplate DataType="{x:Type vm:BViewModel}">
<vw:BView />
</DataTemplate>
<ContentControl x:Name="chartScreen" Content="{Binding Screen}" Background="Yellow" />
</UserControl>
As you can see from the above code, ContentControl sets its content by binding to the ViewModel Screen property. The Screen property will return an instance of AViewModel or BViewModel depending on some state. The problem is that when UserControl loads onto the screen, the Screen property is NULL, so there is no content yet. At the moment, I would like to set some background for ContentControl, but I cannot find a way how to do this? Background = "Yellow" does nothing ...
Any ideas on how to set the ContentControl background? This backgound should always be applied, even when the content displays AView or Biew, or null.
Goran source
share