Showing posts with label binding. Show all posts
Showing posts with label binding. Show all posts

Tuesday, June 7, 2011

Bind to static ObservableCollection



Wednesday, September 22, 2010

XAML bind control to code-behind property

Say you want to bind, in Xaml, a control's property (ListView.ItemsSource) to a property defined in code-behind (MyItems), in a window or user control.

First, the code-behind property should be declared as a (normal) Propoerty or a DependecyProperty:

C#:


To bind, in Xaml, the ListView to this property, you need to:
XAML:

Sunday, September 12, 2010

Using system colors in WPF

What is the best way to use the system colors in a WPF application? Say you want to draw a rectangle with the background color set to one of the system colors, say the color of the active title bar. The main problem is that this color is not the same, it varies with the Windows theme used and might be different from one computer to another.

XAML: