DotVVM Tip 05: Access parent context using _parent or _root


DotVVM Tips is a series of short articles showing interesting features of DotVVM. To learn more, visit our Docs site.

DotVVM syntax is different from Razor. Instead of passing lambda expressions, use _root, _parent or _this expressions to reference different scopes in your viewmodel.

// Razor
<button type="button" 
        @onclick="@(() => RemoveTopping(topping))">

// DotVVM
<dot:Button Click="{command: _root.RemoveTopping(_this)}">

If you need to jump two scopes up, you can use _parent2. You can also create a child scope by setting the DataContext property to some expression. All bindings inside the blocks will be evaluated within the specified binding context.

Tomáš Herceg
Tomáš Herceg


I am the CEO of RIGANTI, small software development company located in Prague, Czech Republic.

I am a Microsoft Regional Director and Microsoft Most Valuable Professional.

I am the author of DotVVM, an open source .NET-based web framework which lets you build Line-of-Business applications easily and without writing thousands lines of Javascript code.

Ostatní články z kategorie: DotVVM Blog