I have tried clone rendering of inbuilt promo component in Sitcore SXA ,that is a controller rendering. Is it possible to create a custom view rendering? If yes, then how to access the SXA model fields in .cshtml view in Visual Studio.

Followed the link for custom SXA controller rendering

Specification detail

Sitecore 10.2
Visual Studio 2022
  • SXA just an add on module, anything you can do in Sitecore without SXA you can do with SXA. You would create the view just like a normal view rendering.
    – Richard Seal
    Commented Mar 20, 2022 at 16:46
  • @RichardSeal Can you provide any links on how to access the fields in .cshtml file with the help of SXA similar to the way we do in Sitecore. Commented Mar 21, 2022 at 7:38

2 Answers 2


You can create controller rendering in SXA and use Sitecore APIs to fetch the item data onto the model from the page and add your custom rendering to

Presentation --> available renderings --> Page structure.


Try this,

Create a custom view rendering and use this code in your .csthml file.

@using Sitecore.XA.Foundation.RenderingVariants.Extensions
@using Sitecore.XA.Foundation.SitecoreExtensions.Extensions
@using Sitecore.XA.Foundation.Variants.Abstractions.Fields
@model Sitecore.XA.Foundation.Variants.Abstractions.Models.VariantsRenderingModel

@if (Model.DataSourceItem != null || Html.Sxa().IsEdit)
    if (Model.DataSourceItem == null)
        --- USE Model.DataSourceItem to get fields. 

You will be able to get the fields from your datasource template.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.