我有些命令綁定在我的XAML定義:WPF:問題採取命令處理出來的代碼背後
<UserControl.CommandBindings>
<CommandBinding
Command="commands:Commands.GrantAccessCommand"
Executed="HelpExecuted" />
</UserControl.CommandBindings>
所以GrantAccessCommand位於所謂的命令和HelpExecuted是在我的代碼後面一個單獨的類。它工作正常。現在,當我將HelpExecuted放在其他類中時,我得到一個錯誤「... HelpExecuted」不是有效的事件處理程序方法名稱,只有生成的或代碼隱藏類中的實例方法纔有效。代碼:
Executed="commands:Commands.HelpExecuted"
//I also tryed: Executed="x:Static commands:Commands.HelpExecuted"
我知道我可以在代碼中做到這一點的背後使用CommandBindings.Add(新的CommandBinding(GrantAccessCommand,HelpExecuted));但我想用XAML來做到這一點
有沒有辦法?
您使用的是.NET 3.5還是.NET 4? – 2010-12-03 17:55:35