WPF改变窗口尺寸,修改控件尺寸

window中添加 SizeChanged事件

然后:

            grid1.Width = this.ActualWidth;
            grid1.Height = this.ActualHeight;
            var w = this.ActualWidth - 15;
            var h = this.ActualHeight - 38;
            textbox1.Width = w < 0 ? 0 : w;
            textbox1.Height = h < 0 ? 0 : h;

猜你喜欢

转载自blog.csdn.net/liangyely/article/details/104638470