I have the following ComboBox
in WPF. I know that I can add option ALL
with CompositeCollection, but I don't know how. It would be great if somebody help me out with a short tutorial.
<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>
The combo box can also be a stand-alone combo box on the Access form. In this How To, I will show to add the <All> or <N/A> option on the list of combo box. The selection option: <All> or <N/A> is not listed on the table, but we can add on top of the list in the combo box. I have created a from below and added the combo box for selecting the state.
We want to add <All> option on this combo box. Under the Data tab of the property sheet of the combo box, you will see the Row Source in the picture below: Row Source = SELECT [Customers]. [ID], [Customers]. [State] FROM Customers ORDER BY [State]; Actually, there are two fields/columns in the combo box.
In the after update event for the combo box have you tried to requery the combo box. I think you misunderstood me. I've got a combobox linked to a static table. Mostly people will be querying using specific options from the combobox (status codes). But mgt need to be able to query it seeing all status's.
Binding Enum to Combobox – We can bind an enum to the combobox by creating an ObjectDataProvider in the resource and binding it to the combobox as shown in the snippet below. I have created an enum Gender and binded it to combobox. 4. Binding to SelectedValue and SelectedValuePath –
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With