Class NavigationTreeViewModel
- Namespace
- Dynamicweb.Frontend.Navigation
- Assembly
- Dynamicweb.dll
Represents a navigation tree for use in a rendering context.
public class NavigationTreeViewModel : ViewModelBase
- Inheritance
-
NavigationTreeViewModel
- Inherited Members
Examples
Using the viewmodel in a razor template.
@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.Navigation.NavigationTreeViewModel>
<div>@{RenderNodes(Model.Nodes);}</div>
@functions {
void RenderNodes(IEnumerable<Dynamicweb.Frontend.Navigation.NavigationTreeNodeViewModel> nodes)
{
<ul>
@foreach(var node in nodes)
{
<li>
<a href="@node.Link">@node.Name</a>
@{RenderNodes(node.Nodes);}
</li>
}
</ul>
}
}
Properties
Nodes
Gets the sub nodes (children) to the root node.
public IEnumerable<NavigationTreeNodeViewModel> Nodes { get; }
Property Value
- IEnumerable<NavigationTreeNodeViewModel>
A collection of NavigationTreeNodeViewModel
Parameters
Gets the custom parameters.
Custom parameters can be setted through Parameters and then they can be used in the template that renders the navigation.
public IDictionary<string, object> Parameters { get; }
Property Value
- IDictionary<string, object>
The parameters as an IDictionary<TKey, TValue> where TKey and TValue are both string.