0

Scenario: we have a WPF .NetCore 3 App and a .NetCore Web app that use signalR to pass data between the two, right now I have two copies of the models - one in each VS Project. Its a pain to keep them in sync.

I know I can use a common .NetStandard Class Library Project to do this but the WPF projects model has INPC annotations and uses MVVM Light.

So I have the same properties in both but one has the INPC & MVVM Light helpers.

Am I stuck with having to keep the two models in sync or is there a better way to do this?

Fredrik Lundin
  • 8,006
  • 1
  • 29
  • 35
tinmac
  • 2,357
  • 3
  • 25
  • 41
  • 1
    My suggestion would be to use a [shared code project](https://stackoverflow.com/q/30634753/87698) (that's different from a class library) with either conditional compilation or partial classes. That's how we share code between .NET 3.5 and Xamarin. – Heinzi Jul 05 '19 at 13:02
  • 1
    There is a [.NET Standard compliant version of MvvmLight](https://www.nuget.org/packages/MvvmLightLibsStd10/) available that you should be able to use. Or what exactly is your issue? – mm8 Jul 05 '19 at 13:15
  • 2
    Can you give examples of your classes? What features do they depend on? *Model* classes shouldn't depend on MVVM Light while *ViewModel* classes are specific to their views, so not really appropriate for a .NET Standard class library. In any case, [INPC](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.inotifypropertychanged?view=netcore-3.0) is available since .NET Core 1.0 and .NET since 2.0. It's not specific to WPF. This means the only problem is the dependency on MVVM Light – Panagiotis Kanavos Jul 05 '19 at 13:16
  • @PanagiotisKanavos thanks, I was using MvvmLights __Set__ helper in the model but ive stripped it away and now simply using the usual __OnPropertyChanged__ method. The comments here really helped, a simple reassurance thing. – tinmac Jul 05 '19 at 14:40

0 Answers0