Getting started
Adorners
Most adorners are accessible via some attached properties of the class
Thinktecture.UIAnnotations.Annotations.
The following sample attaches a watermark (or CueBanner) text to a TextBox.
<TextBox xmlns:uia="clr-namespace:Thinktecture.UIAnnotations;assembly=Thinktecture.UIAnnotations"
uia:Annotations.CueBanner="Enter your name!"
At runtime it looks like that:
Behaviors
With
thinktecture UIAnnotations you can attach Adorners and Behaviors via Markup. There are two models for that:
- the default behavior declaration using the System.Windows.Interactivity.Interaction class
- via an attached property of the Thinktecture.UIAnnotations.Behaviors.BehaviorFactory class
Here is a sample that shows the declaration of the
Thinktecture.UIAnnotations.Behaviors.OpenFileBehavior via the
Interaction class.
<Window
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:uia="clr-namespace:Thinktecture.UIAnnotations; assembly=Thinktecture.UIAnnotations" ...>
...
<Button >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<!--shows the file open dialog and outputs the selected file to a textbox-->
<behaviors:OpenFileBehavior
TargetName="imageTextBox"
DialogTitle="Select an image..."
Filter="PNG Files|*.png" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<TextBox x:Name="imageTextBox" />
...
</Window>
Alternatively,you can set the behavior via the
BehaviorFactory class. This is usefull if you want to assign a behavior via style.
<Window xmlns:behaviors="clr-namespace:Thinktecture.UIAnnotations.Behaviors; assembly=Thinktecture.UIAnnotations" ...>
<Window.Resources>
<Style TargetType="TextBox">
<!--assign behavior in a style via BehaviorFactory-->
<Setter Property="behaviors:BehaviorFactory.BehaviorTypeName"
Value="Thinktecture.UIAnnotations.Behaviors.FocusBehavior" />
</Style>
</Window.Resources>
</Window>