0

I am working on a WPF project where an algorithm executes and depending on the result obtained, polygons on a canvas are adjusted. It is convenient to initialize all objects and call algorithms directly from the main window (where the UI in handled) as this will then make it easy to update the actual locations of the polygons.

What would be a better way to do it?

My first approach was to create a new class to handle flow and communicate with the UI using events. Would this be a better approach?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
  • Please consider using MVVM patter for your WPF application. http://stackoverflow.com/questions/1405739/mvvm-tutorial-from-start-to-finish – Pylyp Lebediev Oct 25 '15 at 10:05

2 Answers2

0

You should definitely look for MVVM Pattern, for start you may want not to realize it as hard as MS Prism does, but simply create MainWindowVieModel and bind your View to it.

kb9
  • 349
  • 2
  • 7
0

In my opinion , you should seek to use the MVVM . However, if some actions become too complicated to be done well , I think it is worth using the MainWindow . There is no reason to complicate . But remember that you will not have as create automated tests for methods that control View and who are not in ViewModel because you have not removed the coupling.

Guilherme Fidelis
  • 1,022
  • 11
  • 20