我只是在学习PRISM所以可能这是一个非常简单的错误:我试图在'Style'中定义Region并且找不到它们:( :(
在主'Shell'窗口中,我有'ContentControl',其中包含'Frame'对象。 'ContentControl'在附加的ResourceDictionary中设置样式,并在那里定义了所有区域(带有其他颜色,画笔,按钮,网格等等)但是无论何时程序运行(所有正确显示在屏幕上),IRegionManager.Regions都是空集合......
我可以做些什么来使用'Style'中的区域???
这是代码:
Shell.xaml
<UserControl x:Class="CardManagment.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"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
d:DesignHeight="300"
d:DesignWidth="400"
mc:Ignorable="d">
<ContentControl HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Style="{StaticResource MainWindowStyle}">
<sdk:Frame x:Name="MainFrame"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderBrush="#FFFB0000"
Style="{StaticResource GlobalNavigationFrameStyle}"
UriMapper="{StaticResource GlobalUriMapper}" />
</ContentControl>
</UserControl>
和ResourceDictionary:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Regions;assembly=Microsoft.Practices.Prism"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit">
<Style x:Key="MainWindowStyle" TargetType="ContentControl">
<Setter Property="Foreground" Value="#FF000000"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContentControl">
...
...
...
<Border Grid.Row="1" BorderThickness="2" CornerRadius="2" BorderBrush="#FFDC1EBA">
<ContentControl x:Name="GlobalLogoRegion" prism:RegionManager.RegionName="GlobalLogoRegion" />
</Border>
...
...
答案 0 :(得分:0)
好的 - 现在我在此页面找到了答案:Regions inside DataTemplates in Prism v4 using a region behavior
实际上,根据这篇文章,它是PRISM中的一个已知错误。