Связывание ComboBox между моделями представления - PullRequest
0 голосов
/ 09 апреля 2019

У меня есть ViewModel (SortingChart) внутри другого ViewModel (Sorting). Я хочу использовать ComboBox в Сортировке, чтобы выбрать сумму, которая используется в SortingChart. Как я могу использовать Combobox от другого ViewModel

Кодовая сортировка:

public class vmSorting : VMBase
{
    //The ComboBox I want to use in the other vm.
    private ComboBox _SelectTop;
    public ComboBox SelectTop
    {
        get { return _SelectTop; }
        set { _SelectTop = value; NotifyPropertyChanged(); }
    }

    //The content in which the (SortingChart) is loaded.
    private object _MyContent;
    public object MyContent
    {
        get { return _MyContent; }
        set { _MyContent = value; NotifyPropertyChanged(); }
    }

    //For the Update button.
    private RelayCommand _cmdUpdate;
    public ICommand Update
    {
        get
        {
            if (_cmdUpdate == null)
                _cmdUpdate = new RelayCommand(param => this.Button_Click_Update(param));
            return _cmdUpdate;
        }
    }

    private void Button_Click_Update(object sender)
    {
        if (sender as string == "UpdateChart")
            MyContent = new AlarmsTopSortingChart();
    }
}

Сортировка кода:

public class vmSortingChart : VMBase
{
    //Here I want to use the selecteditem from the combobox in (Sorting)
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...