Reputation: 386
My Visual Studio 2010 designer crashes with this error:
Error 3 Type 'vm:MessageViewModel+MessageAction' was not found.
This is the line causing the error:
<Button Content="View" Command="{Binding Path=ActionCommand}" CommandParameter="{x:Static vm:MessageViewModel+MessageAction.OpenView}"/>
Keep in mind the program compiles and runs fine. The parameter is even passed correctly to the command.
The enum is inside a class so I need to use the plus sign to reference it. This is the class structure:
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;
}
}
}
Just wondering if there is a reason this doesn't work in the VS designer. If I move the enum outside of the of the MessageViewModel
class the designer doesn't crash.
Upvotes: 0
Views: 229
Reputation: 65
visual studio can be a pain sometimes no? Not sure if this will help but can you make it a Dynamic Resource so it only loads at run time. Hope this helps - Rick CommandParameter="{DynamicResource {x:Static vm:MessageViewModel+MessageAction.OpenView}}"/>
Upvotes: 1