如何在 MVVM 中使用 Prism 框架 auto-click 一个按钮?
How to auto-click a button with Prism framework in MVVM?
正如标题所说....
在我的 ViewModel 的构造函数中,我订阅了一个事件:
eventAggregator.GetEvent<SendControlsForAnimationEvent>().Subscribe(FadeinMainButtons);
然后在订阅者方法中,我想编写一些逻辑来 auto-click 按钮:
private void FadeinMainButtons(string argument)
{
}
我该怎么做?
如果你真的在做 MVVM,在你的 ViewModel 中你应该有一个方法或命令连接到你的按钮的 Click 事件。所以就叫它:
private void FadeinMainButtons(string argument)
{
CallMyMethod(arguement); // if it's a method
MyClickCommand.Execute(argument); // if it's a command
}
正如标题所说.... 在我的 ViewModel 的构造函数中,我订阅了一个事件:
eventAggregator.GetEvent<SendControlsForAnimationEvent>().Subscribe(FadeinMainButtons);
然后在订阅者方法中,我想编写一些逻辑来 auto-click 按钮:
private void FadeinMainButtons(string argument)
{
}
我该怎么做?
如果你真的在做 MVVM,在你的 ViewModel 中你应该有一个方法或命令连接到你的按钮的 Click 事件。所以就叫它:
private void FadeinMainButtons(string argument)
{
CallMyMethod(arguement); // if it's a method
MyClickCommand.Execute(argument); // if it's a command
}