When waiting for changes in the MVVM pattern, there are many ways to implement the INotifyPropertyChanged interface on your own objects. For example, each of the next approaches has benefits and drawbacks: Manually implement the interface. This can be good for small projects, because you will have no dependencies on other libraries. On the other […]
Archive | WPF Wednesday
Creating Branches with Commands
In the previous article, Creating Composite Commands, we have seen a command composition pattern that is like a sequence. In this article, we are going to explore one resembling to branching. With the combination of the two, complex workflows can be described as reactions to user initiated actions. CanExecute The CanExecute method of this command […]
Creating Composite Commands
In the previous week’s article, Why Should You use Commands in WPF Applications, we explored the benefits of using commands in the WPF applications. Now that we’ve seen how useful can this be, here is an interesting trick. You can think of a command as a function that is changing or processing an object in […]
Why Should You use Commands in WPF Applications
The command pattern is old in the software industry. The earliest date that I’ve found that it was published is in the Design Patterns book, by the “Gang of Four”, which was first published in 1994. Most likely it was around earlier, otherwise would not make the book. While it is a well-known pattern, the […]
Creating Attached Properties
Attached Properties are a special kind of dependency properties. They are most likely used to specify some layout information that is containing information for the containing control, not the control that on which we set it. To demonstrate the usage of the attached properties, we are going to implement a simple layout control which has […]
Creating Binding for a Property – from Code
Dependency properties are making easy to attach a user interface to a specific property of the code from XAML. However, attaching the user interface to the same property is not possible only from the XAML. We can do the same from the code too. The completed solution for this article can be found in the […]
Working with Collections on the User Interface
When working with collections attached to the user interface in WPF, there is a little trick that you should be aware of. Consider the source code of the Z09_ObservableCollections project in the WpfWednesday repository. On the MainWindow user interface, the left and the right of the panel looks the same – not counting the difference […]
Attaching Event Handlers to Dependency Properties
In the previous articles, we investigated how to create dependency properties. Beside binding them to properties in XAML, it is useful to attach event handlers to them to be notified about change events. The example code for this article is in the WpfWednesday git repository, in the Z08_AttachingEventHandlers project. There are two methods to attach […]
Read-only Dependency Properties
In the previous article, titled Dependency Properties, we explored how to create dependency properties for our class. In this article, we are going to explore how to create dependency properties that can only be updated in the defining class itself. As a result, these properties are read-only. The example for this article can be found […]
Dependency Properties
In this article, we are going the explore how to create dependency properties. Dependency properties with a special property information that allows the WPF system to interact with them through the XAML code. They also need to be implemented in a specific way because of how WPF interacts with them. As an example, we are […]