Getting started


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:



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.

  xmlns:uia="clr-namespace:Thinktecture.UIAnnotations; assembly=Thinktecture.UIAnnotations" ...>
  <Button >
      <i:EventTrigger EventName="Click">
        <!--shows the file open dialog and outputs the selected file to a textbox-->
          DialogTitle="Select an image..."
          Filter="PNG Files|*.png" />
  <TextBox x:Name="imageTextBox" />

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" ...>
    <Style TargetType="TextBox">
        <!--assign behavior in a style via BehaviorFactory-->
       <Setter Property="behaviors:BehaviorFactory.BehaviorTypeName"
                     Value="Thinktecture.UIAnnotations.Behaviors.FocusBehavior" />

Last edited May 9, 2011 at 12:30 PM by JoergNeumann, version 3


No comments yet.