Frage

I am porting my first (complex) application from WinForms to WPF. I am still in the research stage. One of the main tasks is separation of concerns (UI from logic), hence I would like to use a MVVM framework. I would like to use one of the more complete frameworks (Caliburn micro / MVVM cross / Prism/ ...)

The problem is this program currently needs access to serial ports in the Model layer (eventually to be replaced by bluetooth in the future). As far as I am aware this serial port requirement rules out using anything that depends on PCL or anything similar.

Further complicating things, the View layer will initially need to contain the WPF ribbon (again to be eventually replaced), which I believe will cause minor headaches with some frameworks.

In the future it would be nice if the majority of the codebase was portable to other OS's (hence the interest in MVVM cross).

Which framework would be easiest to acheive my goals? Or am I completely off track and best off sticking to a plain WPF application that has a separate project for business logic that gets called from a UI project, and moving to MVVM when com ports and ribbons are no longer needed?

EDIT (Update): I have more of an understanding of PCL and its limitations now thanks to this article(MSDN). So it looks like I can use Serial Ports with PCL type frameworks if I have an interface and service locater for it, and have a separate (platform specific) project for the implementation of the serial port.

War es hilfreich?

Lösung

I think you are not totally of track! You are on the right way =)... the thing is ... it depends =).

If you go with WPF or a XAML based language you should definitely take advantage of the MVVM pattern! Because it's about separation of concerns, testabillity and structuring your software. Before you pick a framework I would strongly suggest to dive more into the pattern (or guidance) MVVM itself. As soon as you got a clear understanding the framework is just a choice of taste.

Getting back to your question. SerialPort: In MVVM you would probaly have a IDeviceService which could have an implementation for serial port, one for bluetooth, one for RFID. Your app talks only to IDeviceService and the implementation is easily swap-able with dependency injection (clear separation of concerns).

Ribbons: Ribbons is just the view and with that the representation of your data which is backed up by a viewmodel. If you decide to go with another UI control this can be exchanged as well. It depends surely on the behavior if you need to code a new view model but controls are just the view and should not contain much logic.

If you decide to go cross OS you might consider looking at a framework which builds upon the PCL http://msdn.microsoft.com/en-us/library/gg597391(v=vs.110).aspx ...

https://github.com/MvvmCross/MvvmCross mvvmcross is well appriciated for cross platform .Net MVVM development lately...

But after all I would suggest to try to get used to the MVVM concepts with smaller projects and get familiar and after that it is just your choice of taste to go with any of the framework or might role your own =)...

HTH

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top