Skip to main content

Posts

Showing posts with the label MVVM

Caliburn.Micro + Windows 8 App - How to send parameter between ViewModel's

What do you think about the development process in a C#/XAML app for Windows 8. When we are starting developing an application for this platform we should never forget about MVVM. A great framework for this is Caliburn.Micro. It is a pretty simple and clean framework, with a lot of extensions points. When we will try to navigate between screens we will use INavigationService.NavigateToViewModel<TDestionViewModel>. This will work great. Navigation.NavigateToViewModel<MyFooPageViewModel>(); Each ViewModel need to implement the Screen class. This will give access to all the features that we need in the view mode. But what about sending data from one view to another. The method NavigateToViewModel can accept an parameter of type object. Navigation.NavigateToViewModel<MyFooPageViewModel>(“some data”); Looks good but you will be surprised when you will try to get this data in your destination ViewModel. You will not be able to find this data anywhere. To be able to ac...

How to improve our MVVM application using CallerMemberName

Zilele astea am descoperit cateva noi atribute in .NET 4.5 care ne sunt f. utile intr-o aplicatie MVVM si nu numai. In namespace-ul System.Runtime.CompilerServices o sa gasim cateva atribute noi care ne permite sa accesam informatii despre cine a apelat metoda, la ce linie si locatia fisierului cs. Aceste informatii ne pot ajuta cand vrem sa scriem in log anumite date. In loc sa transmitem ca si parametru de fiecare data cine face apelul, putem sa specificam prin intermediul acestor atribute. In exemplul de mai jos, o logam cine a apelat metoda, locatia fisierului care a apelato si numarul linii de cod de unde s-a facut apelul: public void WriteLog( [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0) { Debug.WriteLine(String.Format("{0}-{1}: {2} ", filePath, lineNumber, memberName)); } ... WriteLog(); // apel me...