This project is read-only.

LayoutSelectorPart passed into view instead of LayoutSelectorPartEditViewModel


Hey guys,

I got an error saying the view was expecting LayoutSelectorPartEditViewModel instead of LayoutSelectorPart. I just changed it so that the created view model shown below (set to model) is passed into the Shape as appose to ContentPart (set to part).

protected override DriverResult Editor(LayoutSelectorPart part, IUpdateModel updater, dynamic shapeHelper)
        // Create a ViewModel for the editor template
        var model = new LayoutSelectorPartEditViewModel()
            LayoutName = part.LayoutName,
            // Available layout names
            AvailableLayouts = _layoutService.GetLayouts().ToList()

        // Attempt update from POST
        if (updater != null)
            updater.TryUpdateModel(part, Prefix, null, null);

        // Editor display factory
        return ContentShape("Parts_LayoutSelector_Edit",
                 () => shapeHelper.EditorTemplate(
                     TemplateName: "Parts/LayoutSelector",
                     //Old Model: part,
                     Model: model,
                     Prefix: Prefix));