Wiki


Wiki Table of Contents

Tags

Page Details

Published by:
1 person found this article useful.

100% of people found this useful
Silverlight Tip of the Day #9 – How to Capture the Size of your Browser when it is Resized.

Filed under: [Edit Tags]

Trong  tutorial này,Tôi sẽ trình bày làm thế nào để  điều khiển kích cỡ  browers của bạn khi nó được thay đổi kích cỡ. Đây là yếu tố cần thiết nếu bạn muốn canh chỉnh các yếu tố của bạn vào browsers borders, đặt vào giữa các kí tự của bạn trên screen, vân vân...

Để thực hiện điều này chúng ta sẽ gắn một  resized event handler đơn giản vào đối tượng App.Current.Host.Content .

Page.xaml.cs:

public Page()
{
    InitializeComponent();
 
    App.Current.Host.Content.Resized += new EventHandler(Content_Resized);
}

Từ nay, chúng ta có thể điều khiển kích cỡ của browser khi nó được thay đổi:

void Content_Resized(object sender, EventArgs e)
{
     double height = App.Current.Host.Content.ActualHeight;
     double width = App.Current.Host.Content.ActualWidth;
}

Thank you,
--Mike Snow

 

 

Recent Comments

By: Trinh Minh Cuong Posted on 05-04-2009 11:42 AM

Hay qua, cam on Quynh rat nhieu!