Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
570
Adding a not selected value to data set in combo box
posted

Hi there

 

I have search the web flat and it seems like my googling skills let me down.  I was not able to add a "not selected" item to a bounded comboBox.  Is there a way to do it with the XamComboEditor?

 

This is what I wanted to do...  But with no success.

 

<igEditors:XamComboEditor ItemsSource="{Binding Source={StaticResource odpStockNo}}"
                                                  ValuePath="IDStockNo"
                                                  Value="{Binding Path=FKStockNo}"
                                                  DisplayMemberPath="StockNo" Name="igCombo">
                            <igEditors:ComboBoxItemsProvider>
                                <igEditors:ComboBoxItemsProvider.Items>
                                    <igEditors:ComboBoxDataItem DisplayText=" not selected " Value="-1"/>
                                </igEditors:ComboBoxItemsProvider.Items>
                            </igEditors:ComboBoxItemsProvider>
                        </igEditors:XamComboEditor>

 

but it seems like it is not possible to add an item to a already bounded object.  Is there a work around?  It cant be that difficult?!  It is standard in asp and WinForms!

 

Regards

Christo

Parents
No Data
Reply
  • 54937
    Verified Answer
    Offline posted

    Chris2L said:
    It is standard in asp and WinForms!

    I can't speak for ASP but in WinForms, you couldn't do both. If you set the ItemsSource then you couldn't add items to the Items collection - it would throw an exception. The same is true for our xamComboEditor and the intrinsic WPF combobox. If you are going to use the ItemsSource then you will need to add an item to the collection or perhaps you could write a custom wrapper collection that adds extra items around the main collection. Another approach is one discussed here regarding use of a CompositeCollection.

Children