Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

AdornedElementPlaceholder Class

Represents the element used in a ControlTemplate to specify where a decorated control is placed relative to other elements in the ControlTemplate.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
[ContentPropertyAttribute("Child")]
public class AdornedElementPlaceholder : FrameworkElement, 
	IAddChild
<AdornedElementPlaceholder/>

Use this class only if you are creating a ControlTemplate that serves as a custom validation ErrorTemplate to provide visual feedback when the user input is not valid.

For example, you might want a red exclamation point to appear next to a text box when the input is not valid, as in the following illustration.

Data binding validation error

The following example shows how to use a ControlTemplate with AdornedElementPlaceholder to create the adorned TextBox in the preceding illustration.

<ControlTemplate x:Key="validationTemplate">
  <DockPanel>
    <TextBlock Foreground="Red" FontSize="20">!</TextBlock>
    <AdornedElementPlaceholder/>
  </DockPanel>
</ControlTemplate>

The AdornedElementPlaceholder element specifies where the control being adorned (the TextBox in this case) should be placed.

You can then specify your template as the ErrorTemplate for your TextBox, as in the following example.

<TextBox Name="StartDateEntryForm" Grid.Row="3" Grid.Column="1" 
    Validation.ErrorTemplate="{StaticResource validationTemplate}" 
    Style="{StaticResource textStyleTextBox}" Margin="8,5,0,5">
    <TextBox.Text>
        <Binding Path="StartDate" UpdateSourceTrigger="PropertyChanged" 
            Converter="{StaticResource dateConverter}" >
            <Binding.ValidationRules>
                <src:FutureDateRule />
            </Binding.ValidationRules>
        </Binding>
    </TextBox.Text>
</TextBox>

For the complete sample, see Data Binding Demo or the Data Validation section in Data Binding Overview.

System.Object
  System.Windows.Threading.DispatcherObject
    System.Windows.DependencyObject
      System.Windows.Media.Visual
        System.Windows.UIElement
          System.Windows.FrameworkElement
            System.Windows.Controls.AdornedElementPlaceholder
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.