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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:48:41+00:00 2026-06-13T14:48:41+00:00

I’ve got a WPF window, and I’m trying to get the Width property. No

  • 0

I’ve got a WPF window, and I’m trying to get the Width property. No matter where I try to present the code, it always returns as NaN. I have looked up on the internet and read that I should actually be using ActualWidth instead, but this returns 0 no matter what.

How can I get rid of the lag and get an actual value for my window’s width?

XAML:

<Window x:Name="TableWindow" x:Class="QueryBuilder.DatabaseTable"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStyle="None" Background="Transparent" SizeToContent="WidthAndHeight" ResizeMode="CanResize">
    <Grid>
        <DockPanel>
            <StackPanel Name="titleBar" DockPanel.Dock="Top" Height="28" FlowDirection="RightToLeft" Orientation="Horizontal" Background="AliceBlue">
                <Button x:Name="btnClose" Margin="0,0,5,0" Click="btnClose_Click">
                </Button>
                <Button>
                </Button>
                <Button>
                </Button>
                <Button x:Name="btnAll">ALL</Button>
                <Label Name="lblTableName" FontSize="15" Margin="50,0,0,0"></Label>
            </StackPanel>
            <StackPanel Orientation="Vertical" Name="spFields">
            </StackPanel>
        </DockPanel>
    </Grid>
</Window>

XAML.cs:

public DatabaseTableWindow(string tableName, DataTable fields, string primaryKey)
        {
            InitializeComponent();
            this.tableName = tableName;
            this.fields = fields;
            this.primaryKey = primaryKey;
            lblTableName.Content = tableName;
            double x = this.ActualWidth;
        }
  • 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-13T14:48:44+00:00Added an answer on June 13, 2026 at 2:48 pm

    As we’ve been chatting in the WPF room regarding this question, this was a compounded problem to seemingly easy thing.

    If we set width / height on mdiChild, we end up losing resize functionality. so I’ve posted a gist with the fix that seems to have solved this issue as per our chat


    so to get the size bound, I used normal bindings (this copy paste from my test project):

    <Window x:Class="TestApplication.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:MDI="clr-namespace:WPF.MDI;assembly=WPF.MDI" xmlns:TestApplication="clr-namespace:TestApplication"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Title="MainWindow">
        <MDI:MdiContainer Name="mainContainer">
            <MDI:MdiChild x:Name="mdiChild" MaximizeBox="False" MinimizeBox="False" Resizable="True" ShowIcon="False" Width="{Binding Width, ElementName=childElement}" Height="{Binding Height, ElementName=childElement}">
                <TestApplication:DatabaseTable x:Name="childElement"/>
            </MDI:MdiChild>
        </MDI:MdiContainer>
    </Window>
    

    this solves the primary width & height issue.


    This piece of code needs to replace the MdiChild.cs Changeset 81799 resize handler source in WPF.MDI library (you can replace the existing relevant code in there with this):

    /// <summary>
    /// Handles the DragDelta event of the ResizeLeft control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragDeltaEventArgs"/> instance containing the event data.</param>
    private void ResizeLeft_DragDelta(object sender, DragDeltaEventArgs e)
    {
        if (ActualWidth - e.HorizontalChange < MinWidth)
            return;
    
        double newLeft = e.HorizontalChange;
    
        if (Position.X + newLeft < 0)
            newLeft = 0 - Position.X;
    
        Width = ActualWidth - newLeft;
        Position = new Point(Position.X + newLeft, Position.Y);
    
        if (sender != null)
            Container.InvalidateSize();
    }
    
    /// <summary>
    /// Handles the DragDelta event of the ResizeTop control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragDeltaEventArgs"/> instance containing the event data.</param>
    private void ResizeTop_DragDelta(object sender, DragDeltaEventArgs e)
    {
        if (ActualHeight - e.VerticalChange < MinHeight)
            return;
    
        double newTop = e.VerticalChange;
    
        if (Position.Y + newTop < 0)
            newTop = 0 - Position.Y;
    
        Height = ActualHeight - newTop;
        Position = new Point(Position.X, Position.Y + newTop);
    
        if (sender != null)
            Container.InvalidateSize();
    }
    
    /// <summary>
    /// Handles the DragDelta event of the ResizeRight control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragDeltaEventArgs"/> instance containing the event data.</param>
    private void ResizeRight_DragDelta(object sender, DragDeltaEventArgs e)
    {
        if (ActualWidth + e.HorizontalChange < MinWidth)
            return;
    
        Width = ActualWidth + e.HorizontalChange;
    
        if (sender != null)
            Container.InvalidateSize();
    }
    
    /// <summary>
    /// Handles the DragDelta event of the ResizeBottom control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragDeltaEventArgs"/> instance containing the event data.</param>
    private void ResizeBottom_DragDelta(object sender, DragDeltaEventArgs e)
    {
        if (ActualHeight + e.VerticalChange < MinHeight)
            return;
    
        Height = ActualHeight + e.VerticalChange;
    
        if (sender != null)
            Container.InvalidateSize();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to select an H1 element which is the second-child in its group

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.