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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:34:36+00:00 2026-05-18T19:34:36+00:00

I have a button in a grid. The size of the button is a

  • 0

I have a button in a grid. The size of the button is a component in the grid layout. I want to change the content of the button programmatically without the button resizing and causing a re-layout of the grid that contains it.

This is the XAML for the grid:

<Grid Grid.Row="0" Margin="5">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
        <RowDefinition />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <Label Grid.ColumnSpan="4" Grid.Row="0" Style="{StaticResource IfStyle}">Don't have Apache Ant yet?</Label>
    <Label Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right">Download URL:</Label>
    <TextBox Name="TxtDownloadUrl" Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="1" VerticalAlignment="Center" />
    <Label Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right">Destination Directory:</Label>
    <TextBox Name="TxtDestinationDir" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" VerticalAlignment="Center" Margin="0,0,10,0" />
    <Button Grid.Row="2" Grid.Column="3" VerticalAlignment="Center" Name="BtnBrowseDestination" HorizontalAlignment="Stretch">...</Button>
    <Canvas Name="ProgressCanvas" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="3" Height="58" Margin="10" SizeChanged="OnCanvasResize">
        <Image Canvas.Left="4" Canvas.Top="4" Source="/VSADTWizards;component/images/Globe.png" Stretch="Fill" Height="48" Width="48" />
        <Image Canvas.Right="4" Canvas.Top="4" Source="/VSADTWizards;component/images/Computer.png" Stretch="Fill" Height="48" Width="48" />
        <Label Canvas.Left="60" Canvas.Top="4" Name="LabelTotalBytes" />
        <Label Canvas.Right="60" Canvas.Top="4" Name="LabelReceivedBytes" />                
    </Canvas>
    <Button Name="BtnInstall" Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Padding="10">Download, Unzip and Install</Button>
</Grid>

To change the content, I’m doing a simple content update like this:

BtnInstall.Content = "Cancel Download";
// or
BtnInstall.Content = "Download, Unzip and Install";

I want to change the “Download, Unzip and Install” text to “Cancel Download” and back without a resize.

I don’t want to set min/max sizes because I want the button to render correctly if someone has a different DPI setting or language or whatever. I do think that freezing the size after it is initially laid out would be ok but I haven’t been able to figure out how to do that.

  • 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-18T19:34:37+00:00Added an answer on May 18, 2026 at 7:34 pm

    If you want to freeze the size after the button has been rendered, you could handle its Loaded event, then set the buttons Width equal to its ActualWidth at that point.

    Colin E.

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

Sidebar

Related Questions

I have a number of buttons within a grid, that all change size based
I have a grid view which contains a button in a template field. I
I have a grid, which I want to add a button at the top
I have a tab panel that gets populated with a grid when a button
I have a xaml code: <Grid> <WrapPanel> <TextBox ></TextBox> <Button Content=GetIt /> </WrapPanel> </Grid>
I have a TextBlock that's on top of a Button in a Grid .
I have a component that inherits from JPanel, I draw a grid on it.
I have, in a window, a Grid that contains a RadioButton , a TextBox
I want to have a 2x2 grid with a buttons inside. This is only
I have button, which fires an event, that deletes a record from the database.

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.