我正在尝试设置默认选定值ItemsSource
我的财产变化ComboBox
我的xaml:
<ComboBox ItemsSource="{Binding SelectedItemsSource, Mode=OneWay}" x:Name="c1">
<i:Interaction.Triggers>
<ei:PropertyChangedTrigger Binding="{Binding ItemsSource,RelativeSource={RelativeSource Self}}">
<ei:ChangePropertyAction PropertyName="SelectedIndex" Value="{StaticResource zero}" TargetName="c1"/>
</ei:PropertyChangedTrigger>
</i:Interaction.Triggers>
</ComboBox>
我的虚拟机中的 Selected ItemsSource 会动态变化,我希望每次发生这种情况时都选择第一个项目。
知道为什么这不起作用吗?
尝试设置属性与当前项目同步 http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.selector.issynchronizedwithcurrentitem.aspx to true
为您的组合框并完全删除触发器 -
<ComboBox ItemsSource="{Binding SelectedItemsSource, Mode=OneWay}"
IsSynchronizedWithCurrentItem="True">
</ComboBox>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)