2013-09-07 15 views
5

WPF'de aşağıdaki ComboBox var. CompositeCollection ile ALL seçeneğini ekleyebileceğimi biliyorum, ama nasıl olduğunu bilmiyorum. Birisi bana kısa bir öğretici ile yardım ederse harika olurdu.WPF'de "Tümü" seçeneğine WPF'de Veritabanından bağlanma seçeneği nasıl eklenir

<ComboBox SelectionChanged="ComboBoxOperatingPoints_SelectionChanged" 
      x:Name="ComboBoxOperatingPoints" 
      DropDownOpened="ComboBoxOperatingPoints_DropDownOpened_1" 
      FontSize="30" 
      HorizontalAlignment="Right" 
      Margin="40,40,0,0" 
      VerticalAlignment="Top" 
      Width="200" 
      Height="50" 
      IsSynchronizedWithCurrentItem="True" 
      ItemsSource="{Binding OperatingPoints}" 
      DisplayMemberPath="name" 
      SelectedValue="{Binding OperatingPointID,UpdateSourceTrigger=PropertyChanged,TargetNullValue=''}" 
      SelectedValuePath="operating_point_id"> 
</ComboBox> 
+0

indirme Bu kullanıcı kontrolü: http://www.codeproject.com/Articles/563862/Multi-Select-ComboBox-in-WPF –

+1

@eranotzap Üzgünüm, bu iş için özel bir kontrol kullanmam gerekmiyor. Bildiğim kadarıyla bir CompositeCollection ile mümkün ve bununla bir yolu varsa bunu öğrenmek istiyorum. –

cevap

8

bu (msdn) deneyin:

<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> 
+0

teşekkürler iyi çalışıyor. –

İlgili konular