xceedsoftware / wpftoolkit

All the controls missing in WPF. Over 1 million downloads.
Other
3.9k stars 877 forks source link

how to use CheckComboBox with mvvm #750

Open xceedsoftware opened 7 years ago

xceedsoftware commented 7 years ago

md110[CodePlex]
hi I am using the CheckComboBox ver 2.0.0 in my wpf mvvm project but I seem unable to bind the selecteditems. when Bind selecteditems to a property in wpf exception errror SelectedItems=quot{Binding SelectedItemAccountUnitGroup } error: 'SelectedItems' property is read-only and cannot be set from markup. Line

how to save All checked items CheckComboBox to database?

i am using EF code First And Mvvm

but only one checked item CheckComboBox save to database

this is my code binding in wpf window: ltxceedtoolkit:CheckComboBox Grid.Row=quot2quot Grid.Column=quot3quot Name=quotxccedcheckquot ItemsSource=quot{Binding AccountUnitGroupList }quot DisplayMemberPath=quotAccUnitGroupNamequot ValueMemberPath=quotAccUnitGroupIDquot SelectedValue=quot{Binding AccountUnitData.AccUnitGroupID}quot SelectedMemberPath=quot{Binding SelectedItemAccountUnitGroup, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}quot

                     IsDropDownOpen=quotfalsequot
                     MaxDropDownHeight=quot100quotgt

i am using SelectedValue=quot{Binding AccountUnitData.AccUnitGroupID}quot

to save to database but this metod only one checked item save

viewmodel: public AccountUnit AccountUnitData { get; set; } //this field for new Instance of my model in view model

public ObservableCollectionltAccountUnitGroupgt AccountUnitGroupList { get; set; }//this list load mylist to CheckComboBox

private AccountUnitGroup _selectedItemAccountUnitGroup;

    public AccountUnitGroup SelectedItemAccountUnitGroup // this field for binding to SelectedItem or SelectedItems
    {
        get { return _selectedItemAccountUnitGroup; }
        set
        {
            if (_selectedItemAccountUnitGroup != value)
            {
                _selectedItemAccountUnitGroup = value;

                NotifyPropertyChanged(quotSelectedItemAccountUnitGroupquot);
            }
        }
    }

please help me by sample with mvvm

thanks

xceedsoftware commented 7 years ago

BoucherS[CodePlex]
Hi,

Can you submit a more complete sample ? I'm having errors trying to build something from the code you pasted.

Have you tried with PropertyGrid.SelectedItemsOverride property ?