【发布时间】:2016-04-28 02:46:33
【问题描述】:
我正在编写一个以编程方式创建几个按钮的 WPF 应用程序。如何为 ViewModel 中的按钮创建 OnClick 命令?我想添加一个命令以使用 ResetButton 清除所有文本框。
new StackPanel
{
Orientation = Orientation.Horizontal,
Children =
{
new Button { Name = "SendButton", Content = "Send", MinWidth = 50, MaxHeight = 30, Margin = new Thickness(5), Background = Brushes.DodgerBlue },
new Button { Name = "ResetButton", Content = "Reset", MinWidth = 50, MaxHeight = 30, Margin = new Thickness(5), Background = Brushes.DarkRed}
}
});
【问题讨论】:
标签: c# wpf mvvm data-binding