Browse by Tags

All Tags » WPF (RSS)
Sorry, but there are no more tags available to filter with.

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:

Synchronizing control properties with the parent control properties in WPF by marianor

Sometimes you need synchronize the properties of a control with the properties of the parent control, in order to accomplish this you can use a binding by element name. In the example below you can see how to make the size of a control equal to its parent...
Filed under:

A WPF wrapper around Windows Form NotifyIcon by marianor

Because WPF do not have a Notify Icon control, I decided implement a WPF control that wraps the Windows Form control. It only covers the basic functionality, but I believe that it is enough for most scenarios. Enjoy it ! The control and the sample are...
Filed under:

Using IValueConverter to format binding values in WPF by marianor

First we need implement the value converter, to accomplish this we need to create a new class that implements System.Windows.Data.IValueConverter, this interface works only for simple binding. If you need to use multi binding you will need implement System...
Filed under:
More Posts