自动调节尺寸的Silverlight控件 [英] Auto sizing Silverlight controls

查看:158
本文介绍了自动调节尺寸的Silverlight控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Silverlight 4中的一个项目。我想知道如果有一种方法可以让我得到主画布伸展到它在举办的浏览器窗口的高度和宽度?

I am using Silverlight 4 for a project. I want to know if there is a way I can get the main canvas to stretch to the height and width of the browser window it is hosted in?

我想内比例承载控制的所有其他主机的浏览器窗口的主控制来调整控制。
这是一个棱镜应用具有Shell.xaml和外壳内的ContentControl中。
在这种情况下,棱镜我想要的内容控制跨屏幕的高度和宽度..而当内它的Page.xaml负载我想页面的用户控件的100%,填补了XAML的全部内容控制。同样,内的Page.xaml如果我有一个网格我想网格将增长到大小不超过一个固定的像素数

I want the controls within to resize in proportion to the main control that hosts all the rest of the controls in the host browser window. This is a Prism application which has a Shell.xaml and a ContentControl within the shell. In this prism case I want the content control to span to 100% of the screen height and width.. and when a Page.xaml loads within it I want the Page's usercontrol to fill up the entire content control of the xaml. Similarly, within the Page.xaml if I have a grid I want the grid to grow to a size no more than a fixed number of pixels

在的Page.xaml的用户控件中网格似乎是正确调整。我遇到麻烦的Page.xaml的根用户控制延伸到浏览器窗口的整个宽度。有没有办法这可以只使用XAML属性来实现?我不想指定高度和宽度为800和1200就像我在下面做了。

The Grid within the Page.xaml's user control seems to be sizing properly. I am having trouble getting the root user control of the Page.xaml to stretch to the entire width of the browser window. Is there a way this can be done using xaml properties only? I dont want to specify the height and width to 800 and 1200 like I have done below.

这是我的code

<UserControl x:Class="MyNamespace.MyClass"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400" 
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
Background="#FF2D8543" 
Height="800" Width="1200"
 >

<Grid x:Name="LayoutRoot" Background="#FFEB0A0A" 
VerticalAlignment="Center" HorizontalAlignment="Center"
Height="Auto" Width="Auto"
 >
</Grid>

感谢您的时间。

推荐答案

的是,使用电网而不是画布作为顶级元素。 电网默认情况下,采取一切可用的空间。

Yes, use Grid instead of Canvas as top level element. Grid takes all the available space by default.

了解更多关于Silverlight的布局系统这里和的这里

Learn more about Silverlight layout system here and here.

更新:

只是删除​​宽度高度用户控件:

Height="800" Width="1200"

通过设置明确那些你正在给控制固定大小。如果没有指定宽度高度控制将采取一切可用的空间。

By setting those explicitly you are giving the control fixed size. If you don't specify Width and Height the control will take all the available space.

这篇关于自动调节尺寸的Silverlight控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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