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:
3.5sp1 introduced TargetNullValue to bindings. This will set the bound property to Null if the value is entered and if your property is Null it will display this value.
Use of Static Factory Methods with x:FactoryMethod
When you have a type that has no public constructor but a static factory method you had to create that type in code in XAML 2006. With XAML 2009 you can use the x:FactoryMethodx:Arguments attribute to pass the argument values.
Advanced "caption" properties
Another thing that is not very clear is the contents of some properties that we are used to contains only text. If the property of a GUI element is of type Object, it is very likely that you can, instead of just setting the text, add a panel of your need that includes a set of controls.
An example of this is the MenuItem, where the
Header
property (which normally just contains text) can contain a set of gui elements wrapped in a panel control (or just one gui element if you need just one).Also note the
Icon
property on the MenuItem. This normally contains an Image element, but this also can contain anything!The Ability to Stuff UIElement(s) into a TextBlock
I don't know how useful (it qualifies as hidden though) this is ... but it sure caught me off-guard when I first ran into it:
You could argue the following xaml could be useful (i.e. putting a graphic at the end of some text):
The above xaml renders like the following:
Sometimes you get string that is too long to show on label. In this case we can make use of
TextTrimming
property ofTextBlock
to show EllipsesMSDN Link
Show Tooltip on a disabled control
Wpf allows to show tooltip on a control, if it is in disabled state.
For example