C#WPF如何设置的位置,宽度和高度的控件编程? [英] c# WPF how to set location,width and height of the controls programatically?

查看:2730
本文介绍了C#WPF如何设置的位置,宽度和高度的控件编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯做我的第一个WPF应用程序。 IM有问题,因此当我的窗体最大化或全屏,我不会控制和调整仅仅停留在相同的位置。 。只有窗体最大化

im doing my first WPF application. im having problem whereby when my form is maximized or fullscreen, my controls wont resize and just stay in the same location. only the form is maximized.

在WinForm的,我可以做调整,如下面的的.cs:

in winform,i can do the adjustment in the .cs like the following:

panel6.Width
panel6.Height
panel6.Location

这会帮我处理它,如果我的方式是maximized.i通过使用一些算术那里我得到屏幕的分辨率和一些计算和获得的价值,并可以将其设置为宽度,高度和做位置。
但是这是在winform。

this will help me set it if my form is maximized.i do it by using some arithmetics where i get the resolution of screen and some calculation and get the value and can set it to the width, height and location. BUT THIS IS IN WINFORM.

我将如何解决这一问题的最大化和全屏在WPF?有没有通过.cs文件编程做的方法吗?还是WPF配有简单的内置的控制来解决这个问题?

how will i tackle this issue for maximized and fullscreen in WPF? is there a way to be done through the .cs file programatically? or does WPF come with a easy built in control to tackle this issue?

假设使用DockPanel中的WPF这个例子IM。

suppose for this example im using dockpanel in the WPF.

如果窗口最大化,但是其他控件仍然将是毫无意义的。

it will be pointless if window is maximized but the other controls remains.

什么想法?

推荐答案

要设置的宽度高度

dockpanel1.width = 230;
dockpanel1.height = 230;



作为位置, WPF 使用<强>保证金

dockpanel1.Margin = new Thickness(0,440,836,40);

这篇关于C#WPF如何设置的位置,宽度和高度的控件编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆