Tuesday, November 18, 2008

Such different paths. Binding in WPF part 1.


Download source files - here

We pleasure to using Binding in WPF. But all ways of using have we known? Only direct binds to dependency property like next code?

<TextBlock Text="{Binding Path=Height, ElementName=myButton}">

This is poor. We can bind to property of value's property. How?
Easy:

<TextBlock Text="{Binding Path=Background.(SolidColorBrush.Opacity), ElementName=myButton}"/>

and

<TextBlock Text="{Binding Path=(Button.Content).(TextBlock.FontSize), ElementName=myButton}"/>

In attached sample I show how we can use this for EventTriggers.

No comments: