How to add option “All” to a combobox in WPF with binding from Database

限于喜欢 提交于 2019-11-30 21:37:26

Try this (msdn):

<ComboBox x:Name="ComboBoxOperatingPoints"  
          SelectionChanged="ComboBoxOperatingPoints_SelectionChanged" 
          Width="200" Height="50"
          IsSynchronizedWithCurrentItem="True"
          DisplayMemberPath="name"        
          SelectedValuePath="operating_point_id">
    <ComboBox.Resources>
        <CollectionViewSource x:Key="comboBoxSource" Source="{Binding Path=OperatingPoints}" />
    </ComboBox.Resources>
    <ComboBox.ItemsSource>
        <CompositeCollection>
            <local:OpPoint name="all" operating_point_id="-1" />
            <CollectionContainer Collection="{Binding Source={StaticResource comboBoxSource}}" />
        </CompositeCollection>
    </ComboBox.ItemsSource>
</ComboBox>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!