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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:58:10+00:00 2026-06-09T10:58:10+00:00

I require the size of an element in a Grid layout after changing its

  • 0

I require the size of an element in a Grid layout after changing its ColumnSpan and RowSpan. The ActualWidth and ActualHeight properties do not reflect the rendered size.

<Window x:Class="SizeTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525" KeyDown="OnKeyDown">
<Grid Name="grid">
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
    <Label Name="testElement" Content="Test" Background="Red" Grid.Row="0" Grid.Column="0" Grid.RowSpan="1" Grid.ColumnSpan="1" />
</Grid>

private void OnKeyDown(object sender, KeyEventArgs e)
{
    var w1 = testElement.ActualWidth;
    var h1 = testElement.ActualHeight;

    Grid.SetColumnSpan(testElement, 2);
    Grid.SetRowSpan(testElement, 2);

    var w2 = testElement.ActualWidth;
    var h2 = testElement.ActualHeight;

    MessageBox.Show(string.Format("Initial size: {0}x{1}\nNew size: {2}x{3}", w1, h1, w2, h2));
}

Output: Initial size: 285.5×160 New size: 285.5×160

  • 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-09T10:58:12+00:00Added an answer on June 9, 2026 at 10:58 am

    ActualWidth and ActualHeight will get you the correct result, when the layout of the grid is updated. So you have to get that two properties in the LayoutUpdated event of your grid or other parent elements.

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

Sidebar

Related Questions

The HTML5 <canvas> element does not accept relative sizes (percent) for its width and
The __shared__ memory in CUDA seems to require a known size at compile time.
require('fortunes') fortune('106') Personally I have never regretted trying not to underestimate my own future
require installed gems are not visible. Test with hpricot which I installed several times:
There is an array (of size N) with an element repeated more than N/2
require 'coderay' puts CodeRay.scan('puts Hello, world!', :ruby).page This code will print full HTML page
require 'sinatra/base' class Foo < Sinatra::Base get('/foo') { 'foo' } end class Bar <
Require a huge help here, since this is affecting our production instance. One of
require_once('/recaptcha/recaptchalib.php'); was in the correct place but the error says: Warning: require_once() [function.require-once]: open_basedir
require 'open-uri' print Enter a URL add = gets open(#{add}) do |f| j =

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.