34903

WPF Module toolbar prism

Question:

Can anyone provide a hint on how I would populate a navigation toolbar similar to the StaffLynx Entity toolbar that the Billy Hollis video displays across bottom of the app?

I only want to show a "Client" icon in the toolbar if indeed the application version running has the Client module loaded and available but am unsure how to perform this MVVM style?

Thanks

Answer1:

What you want is your toolbar to have a region:

<controls:MyToolbar Prism:RegionManager.RegionName="ToolbarRegion" />

Then ensure there is a valid RegionAdapter for the type of your toolbar; You can override ConfigureRegionAdapterMappings in your bootstrapper to register additional region adapters:

protected override RegionAdapterMappings ConfigureRegionAdapterMappings() { var mappings = base.ConfigureRegionAdapterMappings(); var toolbarAdapter = Container.Resolve<MyToolbarRegionAdapter>(); mappings.RegisterMapping(typeof (MyToolbar), toolbarAdapter); }

Then in your modules, you can register views to display in this region, e.g:

public class ModuleA : IModule { private readonly IRegionManager _regionManager; public ModuleA(IRegionManager regionManager) { _regionManager = regionManager; } public void Initialize() { _regionManager.RegisterViewWithRegion("ToolbarRegion", typeof(MyToolbarItem)); } }

Where MyToolbarItem is the view you want to be displayed in the toolbar.

Prism will then automatically instantiate an instance of MyToolbarItem and add it to the region called ToolbarRegion.

Recommend

  • WPf Datepicker Input modification
  • kendo grid column: how to data bind click event in footer template?
  • Outlook 2007 Add-in Deployment as a DLL
  • Handling Enter key of SIP in windows phone application
  • UIView class for drop down list with UIButtons - delegate/protocol issue?
  • Dynamic SQL with variables inside a view (SQL Server)
  • calculate daily averages for 3d array
  • When to use PDO prepared queries. mysql_real_escape error
  • Why can't python-colormath convert sRGB to Adobe RGB?
  • How can I get the maximum number of OpenMP threads that may be created during the whole execution of
  • wpf: update multiple controls via dispatcher
  • How to merge two Request in Laravel
  • It is possible use the same sql azure instance from two different cloud service of two different sub
  • How can I tell a form not to dispose a particular control when it closes?
  • WPF version of .ScaleControl?
  • Overlapping controls in Windows XP
  • IE7 and TinyMCE with Plone
  • Unable to get column index with table.getColumn method using custom table Model
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Is there a perl module to validate passwords stored in “{crypt}hashedpassword” “{ssha}hashedpassword
  • Transactional Create with Validation in ServiceStack Redis Client
  • Hardware Accelerated Image Scaling in windows using C++
  • How do I alternate colors in Flat List (React Native)
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Meteor helpers not available in Angular template
  • Ajax Loaded meta Tags
  • jquery mobile loadPage not working
  • Unanticipated behavior
  • File upload with ng-file-upload throwing error
  • Error creating VM instance in Google Compute Engine
  • Free memory of cv::Mat loaded using FileStorage API
  • Suggestions to manage Login/Logout transitions
  • using HTMLImports.whenReady not working in chrome
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Java static initializers and reflection
  • File not found error Google Drive API
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal