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 6731979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:35:38+00:00 2026-05-26T10:35:38+00:00

I have a text box in a grid, the textbox has a style applied

  • 0

I have a text box in a grid, the textbox has a style applied to it in which I am trying to bind the width to the colum width in the grid.

window.xaml

    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Label Content="Register User" Grid.Column="0" Grid.Row="0" Style="{StaticResource LabelStyle}"/>
    <Label Content="User Name: " Grid.Column="0" Grid.Row="1" Style="{StaticResource LabelStyle}"/>


    <TextBox Grid.Column="1" Grid.Row="1" Style="{StaticResource TextBoxStyle}"/>
</Grid>

DefaultStyle.xaml

<Style TargetType="{x:Type Label}" x:Key="LabelStyle">
    <Setter Property="HorizontalAlignment" Value="Left"/>
    <Setter Property="VerticalAlignment" Value="Center"/>
</Style>

<Style TargetType="{x:Type TextBox}" x:Key="TextBoxStyle">
    <Setter Property="HorizontalAlignment" Value="Left"/>
    <Setter Property="VerticalAlignment" Value="Center"/>
    <Setter Property="Width" Value="{<!--?????????--!>}"/>
</Style>

I have tried a few thing but can’t work out how to bind this.

  • 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-05-26T10:35:38+00:00Added an answer on May 26, 2026 at 10:35 am

    Instead of setting the Width, just set HorizontalAlignment="Stretch"

    <Setter Property="HorizontalAlignment" Value="Stretch"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text box which has a Ajax calendar extender attached. You click
Q: I have a gridview which contains text box as a template field.The grid
I have a xaml code: <Grid> <WrapPanel> <TextBox ></TextBox> <Button Content=GetIt /> </WrapPanel> </Grid>
I have a text box with a certain width and a string. How do
Lets say I have a text box which should have a default value.... and
I have a grid view with a nested text box in it. I would
I have a simply view: <Grid x:Name=LayoutRoot> <TextBox Height=23 HorizontalAlignment=Left Margin=66,66,0,0 Name=textBox1 VerticalAlignment=Top Width=120
I have a user control that has a text box and a button. I
I have an WPF usercontrol that has a TextBox. I set the text Underline
I have the following xaml: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width=150/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <StackPanel Orientation=Horizontal

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.