Why does DisplayMemberPath does not work when put in Style for a WPF ComboBox?
Unless I add DisplayMemberPath on the combobox it does no开发者_如何学JAVAt work. I think it should take it from Style?
I have the comboBox initially disabled. I see it can work when I open another tab with same DataTemplate. Once it works on one instance, it imdly starts working on all. Is is anything to do with tabs?
<Style x:Key="CollectionList" TargetType="ComboBox">
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="IsEditable" Value="True"/>
<Setter Property="IsSynchronizedWithCurrentItem" Value="False"/>
<Setter Property="DisplayMemberPath" Value="Name"/>
</Style>
<ComboBox ItemsSource="{Binding Items}"
Style="{StaticResource CollectionList}"
SelectedItem="{Binding Model.SelectedItem}" />
Change your Style="{StaticResource CollectionList}"
to a DynamicResource
I am guessing it has something to do with the StaticResource getting loaded once, and the TabControl items getting loaded as needed
精彩评论