Hi,
I have encountered an issue with BarComboBox control where the ItemTemplate only seem to affect the ItemsSource and not the SelectedItem. This behavior is inconsistent with the default ComboBox and the Ribbon.ComboBox.
Here is a highly simplified example that demonstrates how to replicate the default behavior and the issue.
<!--WORKING-->
<ribbon:ComboBox
ItemsSource="{Binding MyListOfString, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding MySelectedString,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}">
<ribbon:ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="Test" />
</DataTemplate>
</ribbon:ComboBox.ItemTemplate>
</ribbon:ComboBox>
<!--WORKING-->
<ComboBox
ItemsSource="{Binding MyListOfString, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding MySelectedString,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="Test" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Both of these examples demonstrate the desired behavior, setting both the SelectedItem and the ItemsSource of the ComboBox dropdown to ‘Test’.
Now here's an example in which the ItemTemplate doesn't apply (Essentially the same code):
<bars:BarComboBox
ItemsSource="{Binding MyListOfString, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding MySelectedString,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}">
<bars:BarComboBox.ItemTemplate>
<DataTemplate
<TextBlock Text="Test" />
</DataTemplate>
</bars:BarComboBox.ItemTemplate>
</bars:BarComboBox>
The DataTemplate does not seem to impact MySelectedString as anticipated.
Is this by design, or is there a potential workaround for this situation?
Thank you,
Matt
[Modified 2 years ago]