Access SiteMapBuilderService from View

Topics: Web Client Software Factory
Dec 31, 2010 at 8:52 AM

Hi

I've just started to develope applications with WCSF

I  would like to access the SiteMapBuilderService from the Masterpage in code behind, so that I can create my own menu.

I tried to access throw ApplicationSiteMap.GetList but it don't work

But I couldn't figure out how I could access.

Can anyown explain, how to do it.

I looked into wiki, but I did't find a solution.

 

Best wishes

xxlleedd

Jan 3, 2011 at 4:19 PM

Hi xxlleedd,

As the SiteMapBuilderService is a global service registered by default in the ShellModuleInitializer (as illustrated in the code below), you can access it from your Masterpage's code behind by using one of the approaches described in this article from the documentation.

        protected virtual void AddGlobalServices(IServiceCollection globalServices)
        {
            (...)
            _siteMapBuilderService = globalServices.AddNew<SiteMapBuilderService, ISiteMapBuilderService>();
        }

Take into account that you could also inject that service as a dependency to the master page's presenter. You can read more about the Model View Presenter pattern in this article from the documentation.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi