Resize main window of WPF application programmatically
My application is running on a touch-screen and it has a transparent main window, so only way to resize is using grip, but on the to开发者_Python百科uch-screen it is quite hard to do. I wonder if there is a way to increase the size programmatically.
I have tried using custom commands but the window increases only by a small amount. Here is the code for my command:
private const int sizeIncreaseThreshold = 50;
private double aspectRatio = 2.45;
private void IncreaseSizeExecuted(object sender, ExecutedRoutedEventArgs e)
{
this.Width = this.Width + sizeIncreaseThreshold * aspectRatio;
this.Height = this.Height + sizeIncreaseThreshold;
e.Handled = true;
}
The code syntax above is correct, which means that the sizeIncreaseThreshold value must be small (for the height), or more likely, your aspect ratio is a value less than 1.
In other words, if your aspect ratio is 0.5, and the sizeIncreaseThreshold is 10, you are going to increase the Height by 10, but the width by 5, each time the command is executed.
精彩评论