Friday, August 31, 2018

Going XAML/WPF Requires new threading model, and Legacy WinForms Charting

The conversion from WinForms/VB.NET to WPF/C#.NET is tougher than anticipated. WPF is designed, by way of XAML, to have a data pull, autonomous, UI system. Base on a design pattern called Model-View-ViewModel (MVVM). The pattern should have been called View->Viewmodel->Model (V>VM>M) since the View is only supposed to know about (references) the Viewmodel and the Viewmodel is only supposed know about (references) the Model. I also found out that WinForms Chart class was not ported to or supported by WPF. Therefore, I'm mostly tossing the View/ViewModel binding concerns and concentrating on core functionality of the app.  That is, charting real-time data and while keeping the UI interactive. So that means wrapping the WinForms Charting namespace to work in WPF and converting WinForms BackgroundWorker threads to work in a WPF environment. The application is forced by XAML to be partitioned at a high level into Windows, User Controls and Pages, each locked to their own partial class and inheritance chain. This architecture requires a lot of inter-class access facilitation. Not to mention the added complexity of trying to adhere to the MVVM pattern of the View only knowing of the ViewModel and the ViewModel only knowing of the Model. It's a challenge.

Of course, working with C#.NET is easier than VB.NET.

No comments: