Is this behavior the same as in WPF, where child controls inherit the data context of their parent view?
Yes.
I see that you are not transferring any model to. Will this work just to inherit the layouts and then not need to use partial at all?
If you want to continue to use it, just like you, you can probably just talk about it in more detail and pass on the current partial model.
@Html.Partial("_IndexPartial", Model)
If you look at the source for Html.Partial (view):
public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName) { return Partial(htmlHelper, partialViewName, null , htmlHelper.ViewData); }
Passing the model through htmlHelper.ViewData, you can access the model in the same way in your view using @ {ViewData.Model}, but this is NOT a good practice.
source share