+ 1

How to make filewatcher application in WPF using MVVM

I want to make a filewatcher application in WPF using MVVM. This filewatcher will monitor a certain folder. I can see what my view will be View : a listbox that contains a list of files that were created To fill the listbox, I want to use an observable collection. Where should my filewatcher object be : in the ViewModel or in the model What should be in the model ?

4th Feb 2018, 10:19 PM
sneeze
sneeze - avatar
2 odpowiedzi
0
When using the MVVM pattern you want to separate the code into different roles. View: Where you will have the presentation for you application which in your case is the .xaml files. Model: Where you will have the data models and repositories for you application, in your case the what data to observe and how it should be interpreted. ViewModel: The logic between your View and Model, for example when your collection of data should update in your view or something should happen when you click a button. You can read more about the MVVM pattern here: https://msdn.microsoft.com/en-us/library/hh848246.aspx And if you are still lost I recommend that you look up a tutorial and follow it step by step, Good luck! :D
5th Feb 2018, 8:30 AM
Jacob Gandemo
Jacob Gandemo - avatar
0
I think I understand the theory. I do find msdn quitte hard to read. But I do have difficulty to use the theory in practice. If I use a filewatcher object ( system.io ) in my application. Where should this be ? In my viewmodel because it has events or in my model because it describes the data input. Sorry I am kind of lost.
5th Feb 2018, 12:35 PM
sneeze
sneeze - avatar