Category: WPF

Missing the timer in WPF?

It’s not gone, it has just moved away from being a UI component to become a code class. In WPF it’s called Dispatcher Timer and can be used in the following way: using System.Windows.Threading; public MainWindow() { InitializeComponent(); DispatcherTimer dispatcherTimer = new DispatcherTimer(); // Register method target to execute every tick dispatcherTimer.Tick += DispatcherTimerTick; //

Add a notification icon to your WPF program

I needed to create a WPF program that will run at certain intervals and, when running, always will do it in the background. Not that difficult. But I also wanted it to be accessible through a notification icon down in the right corner on the Windows screen. A little more work, but not that bad.

How to bind a WPF ListView to a list

As with many controls in .Net, binding is a powerful way to display data from a data source. In this simple example we’ll show you how to bind a ListView to a list of objects. We’ll start by defining the data we want in the list by creating a class with properties. In this simple

WPF data change notification from custom classes

When binding a WPF control to a custom-made class, changes to property values in the object won’t automatically appear in the control because the control can’t by default recognize changes. The solution is to let the class implement the System.ComponentModel.INotifyPropertyChanged interface. The Interface exposes one event that you execute every time a property changes value.

Automation of User Interface in WPF

All basic control in WPF has a corresponding AutomationPeer class that implements all the basic functionality a user can do with that control. These classes are named ButtonAutomationPeer and so on. If a user can scroll it then so can you programmatically. All controls implementing AutomationPeer has a few methods in common and for us

Binding WPF element to an object

When binding a WPF element to another WPF element you can use the ElementName property. But when binding to an Object you use the Source property instead. You don’t need to set the source in the element itself. If source isn’t set the system searches for a source set for the DataContext property further up

Element to element data binding in WPF

Data bindings has existed for quite some time in Windows Forms but in WPF it’s more powerful than ever. In this example I’ll show how to create simple databindings inbetween two WPF elements. Data bindings are created through the Bindings class. In this very simple example a label is declaratively bound to a slider so

%d bloggers like this: