【发布时间】:2011-08-29 21:38:10
【问题描述】:
我正在为一个项目使用 Silverlight 4。我想知道是否有办法让主画布拉伸到它所在的浏览器窗口的高度和宽度?
我希望其中的控件与主控件成比例地调整大小,该主控件承载主机浏览器窗口中的所有其余控件。 这是一个 Prism 应用程序,在 shell 中有一个 Shell.xaml 和一个 ContentControl。 在这种棱镜案例中,我希望内容控件跨越屏幕高度和宽度的 100%。当在其中加载 Page.xaml 时,我希望页面的用户控件填充 xaml 的整个内容控件。同样,在 Page.xaml 中,如果我有一个网格,我希望网格增长到不超过固定像素数的大小
Page.xaml 的用户控件中的 Grid 的大小似乎正确。我无法让 Page.xaml 的根用户控件拉伸到浏览器窗口的整个宽度。有没有办法只使用 xaml 属性来完成?我不想像下面那样将高度和宽度指定为 800 和 1200。
这是我的代码
<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>
感谢您的宝贵时间。
【问题讨论】:
标签: xaml browser layout silverlight-4.0