Home Forums WPF controls Xceed Toolkit Plus for WPF retrieve more than one property from the selected item of a multicolumncombobox

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • rebeldev
    Post count: 7
    #43890 |

    Using only the Xceed Toolkit Plus for WPF, version 3.0, I have the MultiColumnComboBox below. “Departments” is an ObservableCollection<T> that has properties “DeptCode”, “DeptName”, and “ShortName”, and “MyModel” has properties “DefaultDeptCode” and “DeptShortName”.

    <xcdg:MultiColumnComboBox ItemsSource="{Binding Departments}"
                              SelectedValue="{Binding MyModel.DefaultDeptCode, Mode=TwoWay}"
                              Grid.Column="2" Grid.Row="2"
                              Height="28" Width="150" Margin="10,0,0,0"
            <xcdg:Column FieldName="DeptCode"/>
            <xcdg:Column FieldName="DeptName"/>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding DeptCode}"/>
                    <TextBlock Text="{Binding DeptName}"

    I understand that this will display a combo box with rows of Departments.DeptCode and Departments.DeptName values, display the selected Departments.DeptCode and Departments.DeptName in the selected item box, and bind the selected Departments.DeptCode to MyModel.DefaultDeptCode.

    I want to modify this combo box to not only set MyModel.DefaultDeptCode to the “DeptCode” of the selected Departments element, but also set or bind MyModel.DeptShortName to the “ShortName” of the selected “Departments” element from the combo box, even though “ShortName” is not displayed. Can I modify the XAML given here to accomplish this, or must I do someting else?

    Thank you.

    Fawzi [Xceed]
    Post count: 722


    Here are some possibilities. You can find the code in the below link. Please reference the Toolkit and DataGrid dll to make it compile ans set the correct LicenseKey. Also, uncomment the commented solution you want to test in file MainWindow.xaml.cs.


    1) via ComboBox.SelectionChanged

    You can set the MyModel values when the selection changes :

    private void AAAcombobox_SelectionChanged( object sender, SelectionChangedEventArgs e )
    if( ( e.AddedItems != null ) && ( e.AddedItems.Count > 0 ) )
    var data = e.AddedItems[ 0 ] as MyClass;
    if( data != null )
    this.MyModel.DefaultDeptCode = data.DeptCode;
    this.MyModel.DeptShortName = data.ShortName;

    2) via a code-behind binding

    You can bin the MyModel to the selectedItem from the ComboBox :

    var codeBinding = new Binding( “SelectedItem.DeptCode” ) { Source = AAAcombobox };
    BindingOperations.SetBinding( this.MyModel, MyModel.DefaultDeptCodeProperty, codeBinding );
    var nameBinding = new Binding( “SelectedItem.ShortName” ) { Source = AAAcombobox };
    BindingOperations.SetBinding( this.MyModel, MyModel.DeptShortNameProperty, nameBinding );

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.