Example
The example below shows how to create the dashboard view.
C#
using EPiServer.Framework.Localization;
using EPiServer.Shell.ViewComposition;
using EPiServer.Shell.ViewComposition.Containers;
using EPiServer.Shell.Web;
using EPiServer.Web.Routing;
namespace EPiServer.Shell.UI.Models
{
[CompositeView]
public class DashboardViewModel : ICompositeView, IRoutable
{
private string _routeSegment;
private IContainer _rootContainer;
private readonly LocalizationService _localizationService;
public DashboardViewModel(LocalizationService localizationService)
{
_localizationService = localizationService;
}
public IContainer RootContainer
{
get
{
if (_rootContainer == null)
{
_rootContainer = new BorderContainer();
TabContainer tabContainer = new TabContainer
{
ContainersPlugInArea = ShellPlugInArea.DashboardRoot,
PlugInArea = ShellPlugInArea.DashboardRoot,
ContainerType = ContainerType.User
};
var defaultTab = new ComponentContainer
{
PlugInArea = ShellPlugInArea.DashboardDefaultTab
};
defaultTab.Settings["numberOfColumns"] = 2;
defaultTab.Settings["title"] = LocalizationService.Current.GetString("/episerver/shell/ui/resources/tabcontainer/newtabname");
defaultTab.Settings["closable"] = true;
tabContainer.Components.Add(defaultTab);
((BorderContainer)_rootContainer).Add(tabContainer, new BorderSettingsDictionary(BorderContainerRegion.Center));
_rootContainer.Settings.Add("id", Name + "_rootContainer");
_rootContainer.Settings.Add("persist", "true");
}
return _rootContainer;
}
}
public string Name
{
get { return "/episerver/dashboard"; }
}
public ICompositeView CreateView()
{
return new DashboardViewModel(_localizationService);
}
public string Title
{
get { return _localizationService.GetString("/episerver/shell/ui/resources/dashboardview/title"); }
}
public string RouteSegment
{
get { return _routeSegment ?? (_routeSegment = "dashboard"); }
set { _routeSegment = value; }
}
public string DefaultContext
{
get { return null; }
}
}
}
Do you find this information helpful? Please log in to provide feedback.