开发者

system.workareaproperty gives wrong values

I'm currently writing a program in c# wpf with a custom window.开发者_运维百科 So because there has to be a custom maximizing state I want to get the height and width of the screen without the taskbar. the systemparamters.workarea property seemed to be the way to go, however the values that it has given me are wrong. Furthermore setting this as the new Maxheight and Maxwidth sets some sort of margin so that there is a small gap at the right and at the bottom of my app even though I explicitly state this.left = 0 and this.left = 0.

Has anybody got experience with this?

Update: requested code (this is run when user clicks maximize button (essentially a switch between maximize and normal)) Also there are no margins or max heights/widths in my designer window, everything is set to auto.

    private void MaxThis(object sender, System.Windows.RoutedEventArgs e)
    { if (WindowState == WindowState.Maximized){
        WindowState = WindowState.Normal;
        }

    else {
        this.MaxWidth = SystemParameters.WorkArea.Width;
        this.MaxHeight = SystemParameters.WorkArea.Height;       
        this.WindowState = WindowState.Maximized;

    this.Top = 0;
    this.Left = 0;
    }
    }

Update: I made a new blank WPF app in Blend, added a button and linked this code to it. Same margin at the right and bottom...


The extra border and spacing you're seeing is the resizing frame. The simplest way to get rid of it is to set

ResizeMode = ResizeMode.NoResize;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜