C# generics with MVVM, pulling the T out of

后端 未结 4 2164
情深已故
情深已故 2021-02-11 09:42

My Model is a generic class that contains a (for example) Value property which can be int, float, string, bool, etc. So naturally this class is represe

4条回答
  •  抹茶落季
    2021-02-11 10:18

    The alternative would be to have an interface IModelValue that would expose T from Model. Then your ViewModel class would look like:

    class ViewModel
    {
       private IModel _model;
    
       public ViewModel(IModel model) { ....blah.... }
    
       public IModelValue ModelsValue {get; set; }
    }
    

提交回复
热议问题