我正在开发小游戏,逻辑与ModelView类中的Attack
方法一起使用,它应该每1秒调用一次,并且还需要生成OnStartup
。我该如何实施呢?
public class MainModelView: BaseViewModel
{
private ICommand attack;
public MainModelView()
{
}
public ICommand Attack
{
get
{
if (this.attack == null)
{
this.attack = new RelayCommand(this.PerformAttack);
}
return this.attack;
}
}
private void PerformAttack(object obj);
}
和XAML
<Window x:Class="ConsoleHeroes.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lib="clr-namespace:ConsoleHeroes.ViewModels"
Title="ConsoleHeroes" Width="1200" Height="700" Name="Main">
<Window.DataContext>
<lib:MainModelView/>
</Window.DataContext>
<Grid>
</Grid>
</Window>