DotVVM Tip 05: Access parent context using _parent or _root
Published: 11/14/2022 1:11:00 PMDotVVM 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))">
x
</button>
// DotVVM
<dot:Button Click="{command: _root.RemoveTopping(_this)}">
x
</dot:Button>
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.

I am the CEO of RIGANTI, a small software development company located in Prague, Czech Republic.
I am Microsoft Most Valuable Professional and the founder of DotVVM project.