What does the AdornedElementPlaceholder do exactly when we use it in the validation controlTemplate?

After several articles and examples showing usage

AdornedElementPlaceholder

I'm still confused by what is the exact functionality that it uses to check xaml?

+6
source share
2 answers

If you use Validations, you need to show the user where (and what) failed to verify, and where the AdornedElementPlaceholder comes into play. This is a Placeholder that has exactly the same UIElement size that you are checking.

Suppose you are checking user input on a TextBox and want to show a red border around the TextBox when the validation fails. Define a ValidationRule and validation template for a TextBox . If the ValidationRule fails, Validation.ErrorTemplate displayed on the TextBox . Inside the AdornedElementPlaceholder template, the Framework is informed where to place your template in the user interface. In our case, the template may look like this:

 <ControlTemplate> <Border BorderBrush="Red" BorderThickness="1"> <AdornedElementPlaceholder /> </Border> </ControlTemplate> 

You should read this article .

+8
source

I believe that the AdornedElementPlaceholder is used to show where the “check indicator element” is positioned relative to the control being checked. That is, if you have a text box, and when the check is not completed, the red on the right appears on the right, I believe (although not 100%) that the AdornedElementPlaceholder is responsible for this positioning.

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

Source: http://msdn.microsoft.com/en-us/library/system.windows.controls.adornedelementplaceholder(v=vs.110).aspx

0
source

Source: https://habr.com/ru/post/972756/


All Articles