Here is a large number of hidden features discussed for variety of languages. Now I am curious about some hidden features of XAML and WPF?
One I have found is the header click event of a ListView
<ListView x:Name='lv'
Height="150"
GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler">
The GridViewColumnHeader.Click property is not listed.
Some of relevant features so far:
See also:
Debugging Animations
Common Errors
If you get the following error: Cannot animate '(0).(1)' on an immutable object instance. it could be that you are run into one of the following limitations:
Use of Non-Default Constructors with x:Arguments
In XAML 2006 objects must have a public default constructor to use them. In XAML 2009 you can pass constructor arguments by using the x:Arguments syntax.
Easy Object References with {x:Reference}
If you want to create an object reference today you need to do a databinding and declare the source with an ElementName. In XAML 2009 you can use the new {x:Reference} markup extension
Set a ValidationError by Code
A ValidatioRule in a BindingExpression only triggers, when the target side of the binding changes. If you want to set a validation error by code you can use the following snippet.
Set the validation error
Clear the validation error
Markup extensions and attached properties are my favorite features, they enable you to extend XAML "vocabulary" in a very elegant way.
Markup extensions
Attached properties
Source for GridViewSort (btw, it uses the
GridViewColumnHeader.Click
event mentioned by Ortus)Grid size sharing (here's a good example). Long story short you can have grid columns and rows share sizes, even across different grids. This will be invaluable for all the people out there who are using DataGrids without the need to edit the data in place.