开发者

how to get RemovedItems or AddedItems from combobox?

开发者 https://www.devze.com 2023-01-06 15:38 出处:网络
what could be done if i want to get the r开发者_JS百科emoved itema dn added items from a comboBox?In any case bind your ComboBox\'s SelectedItem to a property in your ViewModel. The changes could be d

what could be done if i want to get the r开发者_JS百科emoved itema dn added items from a comboBox?


In any case bind your ComboBox's SelectedItem to a property in your ViewModel. The changes could be done to that property in the setter.

Foo _selectedItem;
public Foo SelectedItem
{
    get
    { 
        return _selectedItem;
    }
    set
    {
        oldvalue = _selectedItem; // Do something with the previously SelectedItem
        _selectedItem = value; // Do something with the newly SelectedItem
        // PropertyChange Notification goes here
    }
}


What are you using for binding the items of the combobox? if you are using a ObservableCollection you can use the CollectionChanged event to be notified of those changes. And it would all be done in the ModelView layer were you probably want to.

0

精彩评论

暂无评论...
验证码 换一张
取 消