Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I got the same problem before, and I solve it with this (<a href="https://stackoverflow.com/questions/1314560/notify-datatemplateselector-about-the-change">Notify DataTemplateSelector about the change</a>) hint.</p> <p>My problem was, I want a ContentPresenter which changes embedded UserControl when the ComboBox selection changed.</p> <p>The Combobox+ContentPresenter XAML is</p> <pre><code> &lt;ComboBox Name="comboBoxControl" Grid.Row="1" Grid.Column="1" SelectionChanged="comboBox_SelectionChanged"&gt; &lt;i:Interaction.Triggers&gt; &lt;i:EventTrigger EventName="SelectionChanged"&gt; &lt;cmd:EventToCommand Command="{Binding Path=ChangeControlCommand, Mode=OneWay}" CommandParameter="{Binding Path=SelectedItem.Content, ElementName=comboBoxControlType}" /&gt; &lt;/i:EventTrigger&gt; &lt;/i:Interaction.Triggers&gt; &lt;ComboBoxItem&gt;UserControl-1-&lt;/ComboBoxItem&gt; &lt;ComboBoxItem&gt;UserControl-2-&lt;/ComboBoxItem&gt; &lt;/ComboBox&gt; &lt;ContentPresenter Name="contentPresenter" ContentTemplateSelector="{Binding Source={StaticResource controlCueTemplateSelector}}" Content="{Binding}" /&gt; </code></pre> <p>As you can see, the command binding with MVVM manner was my approach. Although you might not want to write a code-behind, kindly write a code-behind with appropriate event as below.</p> <pre><code> private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var content = contentPresenter.Content; contentPresenter.ClearValue(ContentPresenter.ContentProperty); contentPresenter.SetValue(ContentPresenter.ContentProperty, content); } </code></pre> <p>Bottomline is, you need to reset the binded target object (in my case, the Content property).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload