开发者

Extending ViewModelBase class in MVVM Light toolkit

The MVVM Light toolkit has a ViewModelBase that all ViewModels inherit from. Unfortuna开发者_运维问答tely that ViewModelBase is built into the dll for MVVM Light, so I don't know how to extend it.

I want to add the following code to the constructor of the ViewModelBase.

if (!App.IsAuthenticated) {
//MVVM Navigation code here 
}

I have an IsAuthenticated flag set in my App.xaml.cs that's set to true after a user successfully authenticates with our custom DB/authentication model (running OOB without a membership/role provider).

How do I extend the VMB to include this code?


You can either extend ViewModelBase as proposed, or use extension methods. If you are set on avoiding to extend, the extension method model should help you.


you can get MVVM Light sourcecode from mvvmlight.codeplex.com and modify it.


Create a new class that inherits from ViewModelBase

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜