【发布时间】:2015-01-31 07:14:30
【问题描述】:
我在ShellView 中有一个Button 我希望这个按钮被触发到FooViewModel 但不起作用,任何想法。
<Window x:Class="CM.Views.ShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Button cal:Message.Attach="[Event Click]=[Action FooViewModel.About]"/>
</Window>
namespace CM.ViewModels
{
public class ShellViewModel : Conductor<IScreen>.Collection.OneActive, IShellViewModel
{
public ShellViewModel()
{
}
}
public class FooViewModel
{
public void About()
{
MessageBox.Show("About method fired");
}
}
}
【问题讨论】:
-
我认为 viewmodel 为视图呈现数据和命令。但在这种情况下,您想为另一个视图中的按钮触发命令。你不认为它打破了对 mvvm 的看法吗:?
标签: c# wpf mvvm caliburn.micro