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:

No comments:

Post a Comment