silverlight Prism 项目中的页面布局
好的,我尝试在此处提出这个问题,但没有取得太大成功。尝试了一些技巧,比如这个;如果我错了,请纠正我,但我认为这不是最好的方法。
我想做的是让 silverlight 应用程序跨越整个浏览器区域。我上一个问题中提供的解决方案适用于标准 silverlight 项目,但对于 silverlight Prism 项目,相同的规则似乎并不适用。我认为这与包含页面的 silverlight 模块有关,该页面的主用户控件在 Shell.xaml 的内容控件中加载。
有谁知道如何解决这个问题?
我的 Shell.xaml 的代码如下:
<UserControl x:Class="MyNamspace.Shell"
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"
xmlns:Regions="http://www.codeplex.com/prism"
Background="#FF2D8543"
>
<ContentControl Regions:RegionManager.RegionName="MainRegion"
Background="Black"
VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
>
</ContentControl>
我在 Shell.xaml 的 Contentcontrol 中注册的 Modulepage 的 xaml
<UserControl x:Class="MyNamspace.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"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
MinHeight="800" MinWidth="800"
>
<UserControl.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF2D8543" Offset="1"/>
</LinearGradientBrush>
</UserControl.Background>
<Grid x:Name="LayoutRoot" Background="#FFEB0A0A"
VerticalAlignment="Top" HorizontalAlignment="Center"
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<sdk:Label Height="23" HorizontalAlignment="Left" Margin="64,85,0,0" Name="label1"
VerticalAlignment="Top" Width="252" Content="Login page here" />
</Grid>
我使用不同颜色的原因是因为我想查看 Shell 的用户控件在哪里以及 Contentcontrol 在其中的哪里。我的模块页面也是如此。
再次感谢...
OK, I've tried asking this question here, but with not much success. Tried a few hacks like this one; Correct me if I am wrong but I don't think that is the best way.
What I am trying to do is get the silverlight application to span the entire browser area. The solution provided in my previous question works for a standard silverlight project, but for a silverlight Prism project somehow the same rules don't seem to apply. I think that has something to do with the silverlight module containing the page which has the main user control loading within the Content control of the Shell.xaml.
Does anyone know how to fix this?
The code of my Shell.xaml below:
<UserControl x:Class="MyNamspace.Shell"
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"
xmlns:Regions="http://www.codeplex.com/prism"
Background="#FF2D8543"
>
<ContentControl Regions:RegionManager.RegionName="MainRegion"
Background="Black"
VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
>
</ContentControl>
The xaml of my Modulepage which I register within the Contentcontrol of the Shell.xaml
<UserControl x:Class="MyNamspace.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"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
MinHeight="800" MinWidth="800"
>
<UserControl.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF2D8543" Offset="1"/>
</LinearGradientBrush>
</UserControl.Background>
<Grid x:Name="LayoutRoot" Background="#FFEB0A0A"
VerticalAlignment="Top" HorizontalAlignment="Center"
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<sdk:Label Height="23" HorizontalAlignment="Left" Margin="64,85,0,0" Name="label1"
VerticalAlignment="Top" Width="252" Content="Login page here" />
</Grid>
The reason I am using different colors is because I want to see where the Shell's usercontrol is and where within it is the Contentcontrol. Same goes for my module's page.
Thanks again...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从
LayoutRoot
中删除VerticalAlignment
和HorizontalAlignment
分配。Remove
VerticalAlignment
andHorizontalAlignment
assignments fromLayoutRoot
.