第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

wpf MVVM疑問 求幫忙解析 謝謝!

wpf MVVM疑問 求幫忙解析 謝謝!

眼眸繁星 2018-12-06 13:12:40
初學(xué)者 希望能通俗一點(diǎn)解析 謝謝! 代碼: viewModel 繼承了NotificationObject 這個(gè)就是? 當(dāng)屬性值set 執(zhí)行一個(gè)方法?RaisePropertyChanged ?叫依賴屬性。 ? 同理需要一個(gè)命令屬性 什么一個(gè)委托和委托對(duì)應(yīng)的方法 class MainWindowViewModel : NotificationObject { private double input1; public double Input1 { get { return input1; } set { input1 = value; this.RaisePropertyChanged("Input1"); } } private double input2; public double Input2 { get { return input2; } set { input2 = value; this.RaisePropertyChanged("Input2"); } } private double result; public double Result { get { return result; } set { result = value; this.RaisePropertyChanged("Result"); } } public DelegateCommand AddCommand { get; set; }private void Add(object parameter) { this.Result = this.Input1 + this.Input2; } public MainWindowViewModel() { this.AddCommand = new DelegateCommand(); this.AddCommand.ExecuteAction = new Action(this.Add); } ICommand是定義一個(gè)命令 下面有2個(gè)方法和一個(gè)事件 class DelegateCommand : ICommand { public bool CanExecute(object parameter) { if (this.CanExecuteFunc == null) { return true; } return this.CanExecuteFunc(parameter); } public event EventHandler CanExecuteChanged; public void Execute(object parameter) { if (this.ExecuteAction == null) { return; } this.ExecuteAction(parameter); } public Action ExecuteAction { get; set; } public Func CanExecuteFunc { get; set; } } html綁定?? 問題?Add是怎么和DelegateCommand關(guān)聯(lián)起來的? 上面的代碼是ok 的 。關(guān)聯(lián)后怎么就執(zhí)行了 Execute 里面的ExecuteAction ? 難以理解 求大俠和各位朋友解析下
查看完整描述

5 回答

?
明月笑刀無情

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超4個(gè)贊

this.AddCommand = new DelegateCommand(); this.AddCommand.ExecuteAction = new Action(this.Add); 就是這樣關(guān)聯(lián)的啊兄弟
查看完整回答
反對(duì) 回復(fù) 2018-12-09
?
蠱毒傳說

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超3個(gè)贊

我后面明白了 調(diào)試
查看完整回答
反對(duì) 回復(fù) 2018-12-09
?
慕的地10843

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊

首先要理解DataContext屬性和INotifyPropertyChanged接口的原理。直接接觸MVVM肯定是不行的。
查看完整回答
反對(duì) 回復(fù) 2018-12-09
?
夢(mèng)里花落0921

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超6個(gè)贊

你說的對(duì)
查看完整回答
反對(duì) 回復(fù) 2018-12-09
  • 5 回答
  • 0 關(guān)注
  • 398 瀏覽

添加回答

舉報(bào)

0/150
提交
取消