如何在 C#、Silverlight 4 中调整控件大小以适合浏览器窗口

发布于 2024-09-07 12:03:24 字数 257 浏览 3 评论 0原文

我的主页中有一个选项卡控件。当我将其放在 Visual Studio 的“设计”视图中时,一切看起来都很完美,选项卡控件设置为填充整个页面。但是,当我运行该程序并将其放在最大化的浏览器窗口中时,选项卡控件仍然与原来的大小相同。换句话说,选项卡控件的大小不会与浏览器窗口的大小调整成比例。

所以我想知道是否有一种方法可以更改选项卡控件上的设置,或者可能有一些代码可以强制选项卡控件与浏览器窗口一起调整大小?

(在VS2010中使用C#、Silverlight 4.0)

I have a tab control in my main page. When I have it in the Design view in Visual Studio, everything looks perfect, the tab control is set to fill the entire page. However when I run the program, and I have it in a maximized browser window, the tab control is still the same size as it originally was. In other words, the tab control does not resize proportionally to the browser window resize.

So I was wondering if there was a way to change a setting on my tab control or maybe some code that would force the tab control to resize along with the browser window?

(Using C#, Silverlight 4.0 in VS2010)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

简单 2024-09-14 12:03:24

好吧,经过这几天的修改,我终于找到了答案。我觉得自己像个菜鸟,没有早点这样做,但我查看了页面顶部的标题栏,发现当浏览器窗口最大化时,它会在屏幕上拉伸,而当调整大小时,标题栏会缩小适合。因此,我查看了标题栏的属性,发现它的水平/垂直对齐设置为“拉伸”。我知道,这是一个菜鸟错误,但我从来没有想到“拉伸”是对齐属性中的一个选项。

长话短说,将水平对齐属性更改为“拉伸”,将垂直对齐属性更改为“拉伸”,然后将控件的高度属性设置为“自动”,将宽度属性设置为“自动”,这样您就得到了一个自动调整大小的控件。

Ok, so after tinkering with this for the last couple days, I've finally found the answer. I feel like a rookie for not doing this sooner, but I got to looking at the title bar on the top of the page and noticed that it stretched across the screen when the browser window was maximized and when it was resized, the title bar shrunk to fit. So I looked at the properties of the title bar and saw that it's horizontal/vertical alignment was set to "stretch." I know, it's a rookie mistake, but it just never occurred to me that "stretch" was an option in the alignment property.

Long story short, change the horizontal alignment property to "stretch," vertical alignment property to "stretch," and then set the height property of the control to "auto" and the width property to "auto" and you've got yourself an auto-resized control.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文