嗨,我为视图导航编写了代码,为此我在该按钮的导航区域上添加了按钮单击我想在内容区域中打开视图我的代码是
模块代码
public class ClientModule : ModuleBase
{
public ClientModule(IUnityContainer container, IRegionManager regionManager)
: base(container, regionManager) { }
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion("NavigationRegion", typeof(Navigation));
RegionManager.RegisterViewWithRegion("ContentRegion", typeof(Content));
}
protected override void RegisterTypes()
{
Container.RegisterType<object, Navigation>(typeof(Navigation).FullName);
Container.RegisterType<object,Content>(typeof(Content).FullName);
}
}
}
引导是
public class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
return this.Container.Resolve<Shell>();
}
protected override void InitializeShell()
{
base.InitializeShell();
App.Current.MainWindow = (Window)this.Shell;
App.Current.MainWindow.Show();
}
protected override void ConfigureContainer()
{
base.ConfigureContainer();
Container.RegisterType<IShellViewModel, ShellViewModel>();
}
protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
{
RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();
mappings.RegisterMapping(typeof(StackPanel), Container.Resolve<StackPanelRegionAdapter>());
return mappings;
}
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog;
moduleCatalog.AddModule(typeof(ClientModule));
}
}
我的导航视图有 1 个按钮,如下所示
<StackPanel>
<Button Command="{x:Static infCommands:ApplicationCommands.NavigateCommand}"
CommandParameter="{x:Type views:Content}"
Name="btnTest">Navigate to Content</Button>
</StackPanel>
现在的问题是当我运行我的应用程序按钮时总是显示禁用,任何人都可以告诉我是什么问题以及它的解决方案是什么。
谢谢