赞
踩
- <Button
- Grid.Row="0"
- Grid.Column="1"
- Command="{Binding BtnClick_Number}"
- CommandParameter="7"
- Content="7"
- Style="{StaticResource BtnStyle_Num}" />
- <Button
- Grid.Row="0"
- Grid.Column="2"
- Command="{Binding BtnClick_Number}"
- CommandParameter="8"
- Content="8"
- Style="{StaticResource BtnStyle_Num}" />
- public RelayCommand<object?> BtnClick_Number { get; }
-
- //构造函数中:
- BtnClick_Number = new RelayCommand<object?>(OperNumber);
-
- //函数实现:
- private void OperNumber(object? obj)
- {
- if (FxShow != null && obj != null)
- {
- FxShow = FxShow.Insert(FxShowSelectStart, obj.ToString()!);
- FxShowSelectStart++;
- }
- }
这样便可以实现在一个函数(OperNumber)中根据不同的CommandParameter区分不同的按钮点击事件。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。