Reputation: 23285
Is there any way I should be designing a C# app if I want to convert it from Winforms to WPF later down the track?
I would already plan on having a separate data layer in a different project, but is there anything else that should be done?
Upvotes: 0
Views: 124
Reputation: 4459
Actually you could look into the MVVM pattern, which is widely used in the WPF world. Since both frameworks are in the .NET client framework, you can adapt some WPF classes for your purpose like the ICommand
interface. Although WPF heavily relies on data-binding, some techniques can also be used in WinForms. For example data-bindings on classes that implement the INotifyPropertyChanged
interface are common practice for WPF view-models and also work in WinForms. In WPF you can bind buttons to ICommand
properties of the view-model, where in WinForms you would first assign an event-handler to a button and than invoke the ICommand
implementation. So there is a lot you can do to structure your application and make it easily portable to WPF.
This also has the benefit that you already have a clean separation between the presentation and the business logic. Viewmodels work really great with WPF but that doesn't mean that they can't be used in other frameworks too.
Upvotes: 1