public OptionDemandeVueModel(DemandeOption dOpt) { service = Services.OptionService.Instance; Opt = dOpt; OptionVueModels = new ObservableCollection <OptionVueModel>(); List <Option> options = service.GetOptions(); foreach (Option option in options) { OptionVueModel optionVue = new OptionVueModel(option); OptionVueModels.Add(optionVue); } observerOption = CollectionViewSource.GetDefaultView(OptionVueModels); OptionVueModel current = (from opt in OptionVueModels where opt.opt.NumOption == dOpt.IdOption select opt).SingleOrDefault <OptionVueModel>(); if (current == null) { observerOption.MoveCurrentToFirst(); } else { observerOption.MoveCurrentTo(current); } observerOption.CurrentChanged += CurrentChangedOption; }
private void CurrentChangedOption(Object sender, EventArgs e) { if (observerOption.CurrentItem == null) { observerOption.MoveCurrentToFirst(); } OptionVueModel value = observerOption.CurrentItem as OptionVueModel; Opt.IdOption = value.opt.NumOption; }