:: Home

  login:         
  passwords:  

WPF FAQs

WPF General Questions
Concepts Element Tree
Concepts Dependency Property
Concepts Attached Property
Concepts Routed Events
Concepts Resources.
Concepts Animation
Concepts Freezable Object
Concepts Input and Commands.
Concepts Layouts
XAML Inline Styles and Templates
XAML XML Namespaces
XAML Code Behind
XAML Custom Class
XAML Type Converters
Content Model ItemControl
Content Model HeaderedItemsControl
Content Model HeaderedContentControl
Content Model Content Control
Content Model Decorator Content Model
Content Model Panel Content Model
Documents Serialization and Storage
Documents Annotations
Documents Flow Content
Documents Printing
Graphics and Multimedia Rendering Graphics
Graphics and Multimedia Animation and Timing
Graphics and Multimedia 2D Graphics
Graphics and Multimedia 3D Graphics
Graphics and Multimedia Visual Layer
Control Customization Adorners
Control Customization Stylable controls
Control Customization ControlTemplates
Data Data Binding
Data DragandDrop
Data Serialization
Globalization and Localization Attributes
Globalization and Localization Comments
Globalization and Localization Globalization Struc
Application and Deployment ClickOnce
Application and Deployment Frame
Application and Deployment Page
Application and Deployment Navigation
Application and Deployment Setup
Application and Deployment Window
Interoperability Message Loops Between
Interoperability Win32 in WPF
Interoperability WPF in Win32
Interoperability Windows Forms and WPF
Security Trusted Security
Security Partial Trust Security
Tools Microsoft Expression Blend
Tools ZAM3D
Tools XAMLPAD
Controls ToolTip
Controls TextBlock
Controls TabControl
Controls ProgressBar
Controls PrintDialog
Controls Popup
Controls TextBox
Controls Canvas
Controls ComboBox
Controls ListBox
Controls StatusBar
Controls ToolBar
Controls Context Menu
Controls Expander
Controls DocumentViewer
Controls FlowDocumentReader
Controls GroupBox
Controls GridSplitter
Controls Image
Controls Menu
Controls ScrollBar
Controls Slider
Controls RichTextBox
Controls Border
Controls Buttons

SilverLight Interview Qs

SAP Interview Questions

Oracle Interview Questions

PHP Interview Questions

Ajax Interview Questions

IIS 7.0

OOP Interview Questions

Ruby Interview Questions

Sql Server Interview Questions

Winforms Interview Questions

SharePoint 2007 Questions

Microsoft Crm Questions

Control Customization Adorners Interview Questions & FAQs

Questions and answers for Control Customization Adorners.

31. Control Customization Adorners

    31.1 What is an adorner ?
    31.2 Where can adorners be used ?
    31.3 How to add a custom adorner ?
    31.4 How do I bind an Adorner to an Element ?
    31.5 How do I remove the Adorner from an element ?

31.1 What is an adorner ?

Adorners are a special type of FrameworkElement used to provide visual cues. It can be used to add functional handle to elements or provide state information about the control. There is a class that plays an important role in rendering called "AdornerDecorator". This class determines the placement of the "AdornerLayer" in the visual tree.


31.2 Where can adorners be used ?

  • Adding functional handles to a UIElement that enables a user to manipulate the element in some way (resize, rotate, reposition etc.).
  • Provide visual feedback to indicate various states or in response to various events.
  • Overlay visual decorations on a UIElement.
  • Visually mask or override part or all of UIElement.

Adorners are a special type of FrameworkElement used to provide visual cues. It can be used to add functional handle to elements or provide state information about the control. There is a class that plays an important role in rendering called "AdornerDecorator". This class determines the placement of the "AdornerLayer" in the visual tree.


31.3 How to add a custom adorner ?

The common way of implementing the rendering of visual element is to override the "OnRenderSizeChanged" method and use one or more "DrawingContext" objects to render the adorner's visuals as needed.

Given below is a simple code snippet for adding rounded corners around the adorned element.

[C#]

protected override void OnRender(DrawingContext drawingContext)
{
Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);

// Some arbitrary drawing implements.
SolidColorBrush renderBrush = new SolidColorBrush(Colors.Green);
renderBrush.Opacity = 0.2;
Pen renderPen = new Pen(new SolidColorBrush(Colors.Navy), 1.5);
double renderRadius = 5.0;

// Draw a circle at each corner.
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopLeft, renderRadius, renderRadius);
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopRight, renderRadius, renderRadius);
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomLeft, renderRadius, renderRadius);
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomRight, renderRadius, renderRadius);


}

31.4 How do I bind an Adorner to an Element ?

To bind an adorner to a particular UI element, the following things needs to be done.

Call the static method "GetAdornerLayer()", to get the AdornerLayer associated with the UIElement.

Call the "Add()" method to bind the Adorner to the target UIElement.

[C#]

AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(myTextBox);
adornerLayer.Add(new ControlAdorner(myTextBox));

31.5 How do I remove the Adorner from an element ?

bottom user control
::  Home :: Services ::  Prices ::  Request Quote
Copyright 2007, Megasolutions Ltd