If I want to display something based on a condition, then a simple approach is to use a visibility binding:
<Something Visibility="{Binding ShowSomething, Converter=..." ... />
With this approach, a visual tree is still created and can cause performance problems if it Somethinghas a complex structure (many children, bindings, events, triggers, etc.).
The best approach is to add content through a trigger:
<ContentControl>
<ContentControl.Style>
<Style TargetType="ContentControl">
<Style.Triggers>
<DataTrigger Binding="{Binding ShowSomething}" Value="SomeValue">
<Setter Property="Content">
<Setter.Value>
<Something ... />
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
But what a nightmare, agree? Having several of these dynamic components will pollute xaml and make navigation difficult.
Is there another way?
, , Type , . , , , meh. , -, xaml, .
, , . xaml- , , . , : 1) ;) 2) , . 3) , ( xaml) .