我正在尝试使用棱镜区域管理器显示视图。问题在于视图已添加到RegionManager中,并且设置了ActiveViews,但MainView(StartWindowView)中什么也没有显示。
我的引导程序:
if (HttpContext.Current != null)
{
HttpContext.Current.Items["PerRequestMyCustomProp"] = myCustomPropValue;
}
使用RegionManager.RegionName =“ ContentRegion”的我的MainWindow(StartWindowView):
public class Bootstrapper: UnityBootstrapper
{
private readonly Action<Window> aR;
public Bootstrapper(Action<Window> AR)
{
aR = AR;
}
protected override DependencyObject CreateShell()
{
return Container.TryResolve<Views.StartWindowView>();
}
protected override void InitializeShell()
{
aR(Container.TryResolve<Views.StartWindowView>());
}
protected override void ConfigureContainer()
{
base.ConfigureContainer();
Container.RegisterType(typeof(object), typeof(Views.TestView),"PlotListView");
Container.RegisterType(typeof(object), typeof(Views.SettingsView), "SettingsView");
Container.RegisterType<IAutoCadService, AutoCadService>
(new ExternallyControlledLifetimeManager());
Container.RegisterType<IPlotListViewModel, PlotListViewModel>
(new ExternallyControlledLifetimeManager());
}
}
我的ModelView:
Window x:Class="PlottingFastAutoCAD2016.Views.StartWindowView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Background="LightSkyBlue"
x:Name="window"
xmlns:res="clr-namespace:PlottingFastAutoCAD2016.ViewModels"
d:DataContext="{x:Static res:StartWindowViewModelDesign.Instanc}"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
d:DesignHeight="500"
d:DesignWidth="600">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Button Width="50"
Grid.Column="0"
Padding="0"
HorizontalAlignment="Left"
BorderThickness="0"
Height="Auto"
Click="Button_Click"
Command="{Binding ElementName=window,
Path=DataContext.NavigationCommand}"
CommandParameter="PlotListView"
Background="Transparent">
<StackPanel VerticalAlignment="Stretch"
Margin="3">
<Image Stretch="Fill"
Source="/PlottingFastAutoCAD2016;component/Resources/Icon/printer-.png"/>
<TextBlock Text="Plot"
HorizontalAlignment="Center"
Foreground="White"/>
</StackPanel>
</Button>
<Button Width="50"
Grid.Column="1"
Padding="0"
BorderThickness="0"
Height="Auto"
Command="{Binding ElementName=window,
Path=DataContext.NavigationCommand}"
CommandParameter="SettingsView"
Background="Transparent">
<StackPanel VerticalAlignment="Stretch"
Margin="3">
<Image Stretch="Fill"
Source="/PlottingFastAutoCAD2016;component/Resources/Icon/settings.png"/>
<TextBlock Text="Settings"
HorizontalAlignment="Center"
Foreground="White"/>
</StackPanel>
</Button>
</Grid>
<ItemsControl prism:RegionManager.RegionName="ContentRegion"
Grid.Row="1"
x:Name="contentRegion"
/>
</Grid>
</Window>
任何人都知道发生了什么事?我花了三天时间解决它,但是没有运气。