Export (0) Print
Expand All

AdornedElementPlaceholder Class

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

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[ContentPropertyAttribute(L"Child")] 
public ref class AdornedElementPlaceholder : public FrameworkElement, IAddChild
/** @attribute ContentPropertyAttribute("Child") */ 
public class AdornedElementPlaceholder extends FrameworkElement implements IAddChild
ContentPropertyAttribute("Child") 
public class AdornedElementPlaceholder extends FrameworkElement implements IAddChild
<AdornedElementPlaceholder>
  Child
</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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft