Browse by Tags

All Tags » WPF (RSS)

How to implement Property Changed notification in WPF with a base ViewModel by marianor

Implement property changed notifications is tedious, there are some posts about how to implement it in a strongly-typed way. I decided combine that technique with a way to simplify the implementation of the setter. The first what you need is a base class...
Filed under: ,

Sorting a ListView in WPF – Part II by marianor

Some time ago I wrote a post about how to sort a ListView by clicking on the header of the column. The problem with that solution was that you needed to implement it each time and you have to define an explicit header for each column. As a more general...
Filed under:

Disabling Minimize and Maximize buttons in a WPF Window by marianor

In WPF there is no possibility to control when the Minimize and Maximize buttons are disabled when the WindowStyle is SingleBorderWindow or ThreeDBorderWindow . In Windows Forms there are some properties like ControlBox , MinimizeBox and MaximizeBox that...
Filed under:

How to get notifications in attached properties by marianor

Sometime we need to know when an attached property change its value for a specific FrameworkElement. For example consider the following: < Canvas > < Button x : Name ="move" Content ="Move" Canvas.Left ="10" Canvas...
Filed under:

How to force a binding to update by marianor

It is really very simple, all that we need is the FrameworkElement and the DependencyProperty that we need refresh. I did some extensions method to update the target or the source of the binding: public static class BindingExtensions {    ...
Filed under:

How to disable Copy and Paste for a control in WPF by marianor

By default all the TextBox ’s (an other controls) in WPF have a default ContextMenu that allows copy, paste and cut. You can disable this menu by setting this property as “{x:Null}”, but the keys associated with the menu options still work. In order to...
Filed under:

WPF Validation with Attributes and IDataErrorInfo interface in MVVM by marianor

WPF provides validation infrastructure for binding scenarios through IDataErrorInfo interface. Basically you have to implement the Item[columnName] property putting the validation logic for each property in your Model (or ModelView) requiring validation...
Filed under:

Formating in WPF binding by marianor

Some time ago I wrote a post about how to format fields in a binding expression. It included the use of an IValueConverter to apply the format, now with .NET framework 3.5 SP1 that is not necessary anymore, because it  provides a new parameter in...
Filed under:

Multiselect ListView with checkboxes in WPF by marianor

The main idea to accomplish this is replace the item template in the ListView and the default behavior in the item selection. The first thing we need is generate an item template containing the checkbox an the text we want to show it. The template is...
Filed under:

Sorting a ListView Data Source in WPF by marianor

When you bind a collection to a selector control (Like a ListBox or ListView), internally, WPF creates a CollectionViewSource and a CollectionWiew, so you can sort an filter the data easily inside the control. The first that you need to do is define two...
Filed under:
More Posts Next page »