Tungky
Tungky

Reputation: 33

How do I get the size of the screen?

I want to know the width of the screen to set my popup's width in a Win8 App.

Upvotes: 2

Views: 1556

Answers (1)

Jim O'Neil
Jim O'Neil

Reputation: 23774

Assuming you mean the height and width of the screen (or more exactly the height and width of the application window), you can get that from Window.Bounds

For example, here's code behind a button what will display the current window's width in a text box on that window:

void App68::MainPage::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
    txtWidth->Text = Window::Current->Bounds.Width.ToString();
}

Upvotes: 2

Related Questions