Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8764229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:58:46+00:00 2026-06-13T15:58:46+00:00

I have created a UserControl – a Labeled TextBox which is working pretty well,

  • 0

I have created a UserControl – a Labeled TextBox which is working pretty well, except for the validation template. When there’s an error the validation control template shows up but it fills the whole space including the Label. I only want it to be as big as the TextBox. How to fix this?

Here’s the xaml:

<UserControl x:Class="Infrastructure.CustomControls.LabelTextBox"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Name="LTB">

    <Grid HorizontalAlignment="{Binding}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <TextBlock x:Name="tbl" 
                   FontFamily="{Binding}" 
                   FontSize="{Binding}" 
                   Text="{Binding ElementName=LTB, Path=LabelText}" 
                   Height="{Binding ElementName=LTB, Path=LabelHeight}" 
                   Width="{Binding ElementName=LTB, Path=LabelWidth}" 
                   VerticalAlignment="Center"/>
        <TextBox x:Name="tbx" 
                 Grid.Column="1" 
                 FontFamily="{Binding}" 
                 FontSize="{Binding}" 
                 IsReadOnly="{Binding ElementName=LTB, Path=IsReadOnly}" 
                 MaxLength="{Binding ElementName=LTB, Path=TextMaxLength}" 
                 Text="{Binding ElementName=LTB, Path=Text}" 
                 Height="{Binding ElementName=LTB, Path=TextHeight}"
                 Width="{Binding ElementName=LTB, Path=TextWidth}" 
                 VerticalAlignment="Center">
            <Validation.ErrorTemplate>
                <ControlTemplate>
                    <DockPanel LastChildFill="True" 
                               ToolTip="{Binding ElementName=aep, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
                        <TextBlock DockPanel.Dock="Right" 
                                   Foreground="Red" 
                                   FontSize="14pt" Text="*" 
                                   Margin="-15,0,0,0" 
                                   FontWeight="Bold"/>
                        <Border BorderBrush="Red" BorderThickness="1">
                            <AdornedElementPlaceholder Name="aep"/>
                        </Border>
                    </DockPanel>
                </ControlTemplate>
            </Validation.ErrorTemplate>
        </TextBox>
    </Grid>
</UserControl>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:58:48+00:00Added an answer on June 13, 2026 at 3:58 pm

    Thanks for the response, it helped me figure out where the problem is. And for that i vote it as useful.

    What i did was programmatically query the UserControl validation for errors in the TextBoxChangedEvent and set the validation error manually (http://wpftutorial.net/ValidationErrorByCode.html) for the TextBox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a UserControl called AutorControl with a method to clear its textbox:
I have a custom usercontrol created by myself which belongs to mine baseControls elements.
I have a page with a UserControl (in which linkbuttons are dynamically created). On
I have created a Scrollviewer in WP7, which harbors 3 usercontrol, each one of
I have created Custom User Control which contain TextBox and PasswordBox. it is binding
I have created a UserControl which has several properties. When I add the user
I have created a usercontrol which is basically a button with some nice little
I have created a UserControl which has a button inside and also a style
I have created what I call a LabeledTextBoxWithLookupControl which inherits from UserControl. I've put
I have created a UserControl name TitleBar, which is placed in every view. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.