user3651656
user3651656

Reputation: 185

How to link Window.SizeChanged in a C# Windows 8 App

I don't know how to link use the Window.SizeChanged event properly in developing a C# Windows 8 app.

I have a basic event that I would like to run:

private void OnWindowSizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
{
    // Do something.
}

but I don't know how to make this run when the window's size changes. I tried linking to it on the page element in my XAML file with SizeChanged="OnWindowSizeChanged", but that returns an error (No overload for 'OnWindowSizeChanged' matches delegate 'Windows.UI.Xaml.SizeChangedEventHandler').

How can I fix this problem?

Upvotes: 0

Views: 795

Answers (1)

Shahar Prish
Shahar Prish

Reputation: 4849

Try this:

Window.Current.SizeChanged += OnWindowSizeChanged;

Upvotes: 1

Related Questions