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
555
XamComboEditor Multi-Select set SelectedItems from ViewModel and change DisplayText
posted

Hallo,

1. How can I change the display Text in xamComboEditor by multi selection ?

Example from test1,test2,test3 where test1,test2,test3 are selectedItems to

display test1/test2/test3 ('/' in place of ',').

The EmptyText property is just for the case where nothing is selected, i suppose there

is another property for displaying the Text but it is private ?

2. How can sort those elements ?

Example if someone selects first test3 then test2 and test1, the display text will be

test3,test2,test1, but i want them to be sorted test1,test2,test3.

3. What is the best way to bind to SelectedItems ? I know that the SelectedItems collection

changes when I select some object in the control, but how can I for example set the SelectedItems property

from my ViewModel ? I need this because I get the List of Objects from my Database and I need to set the SelectedItems from

my ViewModel ?

  • 35319
    posted

    Hello,

     

    I am just checking if you require any further assistance on the matter.

  • 35319
    Verified Answer
    posted

    Hi,

     

    Thank you for your post. I have been looking into your questions and in order to replace the delimiter with another symbol you need to set the ‘MultiSelectValueDelimiter’ property of the XamComboEditor like e.g.:

     

    MultiSelectValueDelimiter="/"

     

    If you would like to sort the selected items in the XamComboEditor, you could handle the ‘SelectionChanged’ event of the XamComboEditor and sort the selected items using reflection like e.g.:

     

            private void combo_SelectionChanged(object sender, Infragistics.Controls.Editors.SelectionChangedEventArgs e)

            {

                ObservableCollection<object> sortedSelectedItems = new ObservableCollection<object>(combo.SelectedItems.OrderBy(p => p.GetType().GetProperty(combo.DisplayMemberPath).GetValue(p, null)).ToList());

     

                combo.SelectionChanged -= new EventHandler<Infragistics.Controls.Editors.SelectionChangedEventArgs>(combo_SelectionChanged);

                combo.SelectedItems = sortedSelectedItems;

                combo.SelectionChanged += new EventHandler<Infragistics.Controls.Editors.SelectionChangedEventArgs>(combo_SelectionChanged);

            }

     

    In order to bind the selected items to a collection from your ViewModel you need to define ObsevableCollection of objects and bind the ‘SelectedItems’ property to it.

     

    I am attaching a sample application(ComboEditor_MultiSelection_Separator_Sort.zip) that shows all this functionalities.

     

    Let me know, if you need any further assistance on this matter.

    ComboEditor_MultiSelection_Separator_Sort.zip