Hi I wrote code for view navigation, For that i added button on my navigation area on that button click i want to open view in content area My code is
ModuleCode
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);
}
}
}
Bootstrap is
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));
}
}
and my navigationview have 1 button as below
<StackPanel>
<Button Command="{x:Static infCommands:ApplicationCommands.NavigateCommand}"
CommandParameter="{x:Type views:Content}"
Name="btnTest">Navigate to Content</Button>
</StackPanel>
now problem is when i run my application button always show disable, Can any one tell me what is the problem and what is its solution.
Thanks
I got this working. I was using same code following a pluralsight video about Prism.
Issue was that the only commmand associated with CompositeCommand was not set to Active. After setting IsActive to true, CompositeCommand became active, and button was enabled.
Following is from msdn docs for Prism
The CompositeCommand can be configured to evaluate the active status of child DelegateCommands (in addition to the CanExecute status) by specifying true for the monitorCommandActivity parameter in the constructor. When this parameter is set to true, the CompositeCommand class will consider each child DelegateCommand's active status when determining the return value for the CanExecute method and when executing child commands within the Execute method.
When the monitorCommandActivity parameter is true, the CompositeCommand class exhibits the following behavior:
CanExecute. Returns true only when all active commands can be executed. Child commands that are inactive will not be considered at all.
Execute. Executes all active commands. Child commands that are inactive will not be considered at all.