我的Visual Studio 2010的設計師與此錯誤崩潰使用+時:Visual Studio的WPF設計崩潰的結合
Error 3 Type 'vm:MessageViewModel+MessageAction' was not found.
這是導致錯誤的行:
<Button Content="View" Command="{Binding Path=ActionCommand}" CommandParameter="{x:Static vm:MessageViewModel+MessageAction.OpenView}"/>
記住該程序編譯並運行良好。該參數甚至可以正確傳遞給該命令。
枚舉是在一個類中,所以我需要使用加號來引用它。這是班級結構:
public class MessageViewModel : ModelWrapViewModel<MessageModel>
{
private ICommand _actionCommand;
public enum MessageAction
{
OpenView,
OpenNote,
OpenAcknowledge,
Cancel,
Save,
Acknowledge
}
public ICommand ActionCommand
{
get
{
if (_actionCommand == null)
{
_actionCommand = new RelayCommand(
param => this.DoSomething((MessageAction)param),
param => true
);
}
return _actionCommand;
}
}
}
只是想知道是否有一個原因,這在VS設計師不起作用。如果我移動MessageViewModel
類的枚舉之外的設計器不會崩潰。
你不能這樣做嗎? 'vm:MessageViewModel.MessageAction.OpenView' – sthotakura
沒有在WPF語法上不正確。如果你想在xaml的類中引用類型,你可以使用'+'。使用'.'將不會編譯,所以這是一個倒退。 – baueric
好的,謝謝你的信息:) – sthotakura