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

The Archive Base Latest Questions

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

So I have a button on a window in a grid column. The button

  • 0

So I have a button on a window in a grid column. The button is shown below:

<Button>
    <Border BorderThickness="3" BorderBrush="Red">
        <Grid Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button, AncestorLevel=1}, Path=Width}">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0" Background="LightBlue">bunnies</TextBlock>
            <TextBlock Grid.Row="1" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button, AncestorLevel=1}, Path=Width}" Background="LightBlue">bunnies</TextBlock>
        </Grid>
    </Border>
</Button>

What I see is the example in the left most button below, I’d like it to look like 2 below.

EDIT:
If you add a Width=”1000″ to the first TextBlock, you will see the effect I want, except that then the text is not central to the column any more, it’s central to a block 1000 wide. So what I am after is the binding syntax of the actual column width or the actual button width.

I’ve left in some of the things that I’ve tried, changing the Width of a single column definition, binding stuff, all sorts.

Left = 1 Right = 2

Ignore the dodgy editing on the text, I just want the border to reach the edge of the button.
Thanks

  • 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-13T03:46:32+00:00Added an answer on June 13, 2026 at 3:46 am

    Try this:

    <Button HorizontalContentAlignment="Stretch">
                <Border BorderThickness="3" BorderBrush="Red">
                    <Grid HorizontalAlignment="Stretch">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Row="0" TextAlignment="Center" Background="LightBlue">bunnies</TextBlock>
                        <TextBlock Grid.Row="1" TextAlignment="Center" Background="LightBlue">bunnies</TextBlock>
                    </Grid>
                </Border>
            </Button>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following xaml: <Border BorderBrush=Black BorderThickness=1.5 CornerRadius=5> <Grid ShowGridLines=True> <Grid.ColumnDefinitions> <ColumnDefinition Width=Auto/>
I have main window which has inner grid components. When I press a button
I have the following simpl WPf grid, two columns, a button in each column,
I have a border that contains a TabControl in a HeaderedContentControl: <Border Grid.Column=1 Style={StaticResource
I have a button on the window form and and one method I am
I would like to have a button in my window such that if I
I have a button in a child window. If I am working in the
I have a Switch to window button on my main form that I'd like
I have a button that opens a panel in a popup window and then
I have a button: <button>Click</button> I want click it and open a new window

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.