存在模型 - \ Models \ HeaderPart.cs。 在Driver中,想要创建CategoriesMenuDriver并使用HeaderPart:
public class CategoriesMenuDriver : ContentPartDriver<HeaderPart>
{
private readonly dynamic shapeFactory;
private readonly IMenuAccessor menuAccessor;
public CategoriesMenuDriver(
IShapeFactory shapeFactory,
IMenuAccessor menuAccessor)
{
this.shapeFactory = shapeFactory;
this.menuAccessor = menuAccessor;
}
protected override DriverResult Display(HeaderPart part, string displayType, dynamic shapeHelper)
{
return this.ContentShape("Parts_CategoriesMenu", () => shapeHelper.Parts_CategoriesMenu(
MenuItems: this.menuAccessor.GetMenu<NavigationMenuItem>("UserAccount")));
}
}
但在CategoriesMenu视图中
var headerPart = (HeaderPart)Model.ContentItem.HeaderPart;
Model.ContentItem为null。
我可以在View CategoriesMenu中获取HeaderPart吗?
答案 0 :(得分:0)
你应该可以像这样访问这个部分:
len_input_serial == 14
虽然HeaderPart part = Model.ContentPart;
不应该在那里为空,这很奇怪
修改强> 如果它也为null,您可以尝试自己设置:
Model.ContentItem