在WPF中获取用户控件的位置 [英] Get Location of user control in wpf

查看:368
本文介绍了在WPF中获取用户控件的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个用户控件,当我单击它时会打开一个窗口.我想以相同的宽度(X)和高于用户控件的高度(y)+10
定位窗口 我该怎么办?

如果要设置位置更改,请

Hi,

I''ve got a user control and when i click on it opens a window. I would like to locaete the window in the same width(X) and above the user control height(y)+10
How do i do that?

Thanks

推荐答案

:
公共表格1()
{
initializecomponent();
}



if you want to set location change:
public form1()
{
initializecomponent();
}

to

public form1( int x, int y)
{
 initializecomponent();
this.location=new point(x,y);
}



但是如果您想更改大小,只需更换:

this.location =新点(x,y);



this.size =新尺寸(x,y);

因此,当您呼叫打开表单时,请像这样:
form1 f1 =新form1(150,150);
f1.show();



but if you want to change the size just replace:

this.location=new point(x,y);

with

this.size=new size(x,y);

so when you call to open form call it like:
form1 f1=new form1(150,150);
f1.show();


到sanforjackass,

谢谢您的回复.
但是:
我没有仅适用于表单的属性位置form.locationchange-
活动吗?

您只了解一半的问题-我想根据显示的用户控件来设置Windows位置

谢谢
To sanforjackass,

Hi thanks for your reply.
But:
I dont have property location for my form only form.locationchange -
event?

U understood only half of the quesiton- i want to set the windows location acoording to a user control displayed

Thanks


这篇关于在WPF中获取用户控件的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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