【发布时间】:2020-03-08 19:15:28
【问题描述】:
我是使用 MVVMLight 的 WPF 新手,并且很难掌握事情的工作原理。 我在 xaml 中有一个按钮:
<Button x:Name="button" Content="Button"
HorizontalAlignment="Left"
Margin="29,374,0,0"
VerticalAlignment="Top" Width="75"
Command="{Binding BeginCollectionCommand}"/>
并让视图模型响应按钮按下。
BeginCollectionCommand = new RelayCommand(BeginCollectionCommandExecute, () => true);
我在
上找不到我的问题的答案- 如何将按钮设置为禁用
- 如何将“content=”设置为“working...”
- 项目完成后如何重新启用按钮
- 如何将“content=”设置为“Done”
- 我还想等待 5 秒再将内容设置为“开始”。我相信我可以用 thread.sleep(5000) 做到这一点,但其他部分我不清楚。
View Model 代码将按钮绑定“BeginCollectionCommand”定义为
public RelayCommand BeginCollectionCommand { get; set; }
public MainWindowViewModel()
{
BeginCollectionCommand = new RelayCommand(BeginCollectionCommandExecute, () => true);
//at this point i believe is where i set the button content to "working..."
//and disable.
}
public void BeginCollectionCommandExecute()
{
/// do my working class code
//I think at this point I want to set the code to change button content to
//enable, conent to "done" then wait and set to "start"
}
有人可以帮忙吗?
【问题讨论】:
标签: c# wpf mvvm-light