In previous posts ( Part 1 and Part2 ) I have presented the implementation of a toy application using the Model-View-Presenter pattern and Routed Commands. In this final post, I will present the migration to MVVM. In Part2 , we have reached a point where we have managed to partly centralize the logic that is needed to be implemented for each Command but we were not yet fully satisfied with the wiring that needed to be done in the code-behind file. So, we will try to tackle this problem: Approach #4 Our first
Διαβάστε περισσότερα »
In my previous post , I have presented the first two approaches for implementing the GUI and the logic of a toy application: Approach #1: All the logic in the code behind file. Approach #2: The Model-View-Presenter pattern. In this post, we will pick up from where we stopped, in our route to migrate to the benefits of the MVVM model and the use of Commands. It is recommended to take a look at the previous post in order to get an idea of the application and the two previous approaches) Approach #3: A hybrid MVP
Διαβάστε περισσότερα »
In this post I will try to show the application of the MVP and MV-VM programming approaches and the use of WPF commands in them. I will start with a simple Window in WPF with all the code intertwined in the code-behind file and transform it to a Window with no code at all at the code-behind file, showing the separation between the view and the logic that is achieved with MV-VM and Commands. The Window is the following: The "Add Client" adds a new client, the "Delete Client" removes the selected
Διαβάστε περισσότερα »
Suppose that in a WPF application there are some custom User Controls implemented. During development in some windows that use the custom User Control you may find that the designer cannot load them and instead it gives the following error: "Could not create an instance of type YOURCONTROLHERE" This happens because the designer runs the constructor for the User Control whenever it needs to display it in design mode. Within the constructor something throws an exception. Sometimes this does not mean
Διαβάστε περισσότερα »
This Blog has now a new look ! Hope you like it.
Διαβάστε περισσότερα »
A typical implementation of an entity that supports the INotifyPropertyChanged interface for WPF Binding is for example as follows: public class Detail:INotifyPropertyChanged { private long _iD; public virtual long ID { get { return _iD; } set { _iD = value ; if (PropertyChanged != null ) PropertyChanged( this , new PropertyChangedEventArgs("ID"));} } private string _line1; public virtual string Line1 { get { return _line1; } set { _line1 = value ; if (PropertyChanged != null ) PropertyChanged( this
Διαβάστε περισσότερα »
There are times when you need a task to execute periodically. There are two ways of achieving this: Use the System.Windows.Threading. DispatcherTimer Use the System.Threading. Timer Say now that you want to implement a class the executes DoSomething() periodically and also informs through a delegate to whoever listens whent the execution is performed. The class for DispatcherTimer is as follows: public class DTimer { private DispatcherTimer timer; public event Action < int > DoSomething; private int _timesCalled
Διαβάστε περισσότερα »
In my first blogging days, I received a comment for a post saying how wonderful and special the thing I did was. I was thrilled! Then I received 5 more comments with exactly the same sentence and then 5 more and I realized that this was my first encounter with comment spamming. In order to avoid this I present here a way to add a custom made CAPTCHA ( C ompletely A utomated P ublic T uring test to tell C omputers and H umans A part) in Blogengine.Net (1.4.5.0). The code below is based on ideas from the implementation
Διαβάστε περισσότερα »
We will work with the following database schema: The corresponding domain model is as follows: Entity.cs public class Entity { private long _iD; public virtual long ID { get { return _iD; } set { _iD = value ;} } private string _description; public virtual string Description { get { return _description; } set { _description = value ;} } private IList < Detail > _details; public virtual IList < Detail > Details { get { return _details; } set { _details = value ; } } (...) Detail.cs public class Detail
Διαβάστε περισσότερα »
There are some times when you want to write a specific framgent of the UI in XAML and then intantiate it in a code-behind file. This can also lead to the strange situation of being able to change the UI design completely afer the application has been compiled and shipped. Here is how such thing can be done: Suppose that you have written the following XAML code: < StackPanel xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns : x ="http://schemas.microsoft.com/winfx/2006/xaml"
Διαβάστε περισσότερα »