@*   Xafari Framework version : 17.2.3011.1336   *@

@using DevExpress.ExpressApp
@using DevExpress.ExpressApp.Editors
@using Xafari.Mvc
@using Xafari.Mvc.Templates

@model Xafari.Mvc.Layout.MvcLayoutManager

@{
    var mvcControl = this.Model.ViewItems[1].Control;
    
    var currentFrame = this.ViewData.Frame();
    var frameContainer = this.Model.ViewItems[1] as IFrameContainer;
    try
    {
        if (frameContainer != null && frameContainer.Frame != null)
        {
            this.ViewData.SetFrame(frameContainer.Frame);

            if (frameContainer.Frame.Template == null)
            {
                var mvcNestedFrameTemplate = MvcApplication.Instance.CreateTemplate(TemplateContext.NestedFrame);
                if (mvcNestedFrameTemplate is MvcNestedFrameTemplate) { ((MvcNestedFrameTemplate)mvcNestedFrameTemplate).IsListViewAndDetailView = true; }
                
                frameContainer.Frame.SetTemplate(mvcNestedFrameTemplate);
                
            }

            if (frameContainer.Frame.Template is IMvcControl)
            {
                mvcControl = frameContainer.Frame.Template;
            }
        }
        
        @Html.Xafari().MvcControl(mvcControl).GetHtml()
    }
    finally
    {
        if (frameContainer != null && frameContainer.Frame != null)
        {
            this.ViewData.SetFrame(currentFrame);
        }
    }
}