Get dimensions before adding to the bounds

Source: Internet
Author: User

You have the few options you can does this, forcing-to-call and would make all Window.Measure Window.Arrange the values to being calculated, or you can GE T those values in the Window.Loaded event. This same issue are discussed already on this question.

If you is sizing to content:

Window.Measure(new size (doublepositiveinfinity, double positiveinfinitywindow. Arrange (new rect0, 0, Window. Desiredwidth, Window. Desiredheight             

If you is using an explicit window size:

window.Measure(new Size(Width, Height));window.Arrange(new Rect(0, 0, window.DesiredWidth, window.DesiredHeight));

Or

  public  Mywindow () { loaded< Span class= "PLN" > += delegate{ //access actualwidth and ActualHeight here  }; } 



just had the same issue and Just calling  TextBlock. Measure (New Size ());  aint enough. I had to use TextBlock. Measure (New Size (double). PositiveInfinity, double. PositiveInfinity));  to get a result for  TextBlock. DesiredSize



The key is to realize that setting it in code like this:

sp2.Margin = new System.Windows.Thickness{ Left = 5 };

is equivalent to:

sp2.Margin = new system. Windows. Thickness{ left = 5, top Span class= "pun" >= 0,  Right = 0 bottom =  0 };             
 

Get dimensions before adding to the bounds

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.