XAML equivalent to DIV in HTML?

Viewed 15396

What I want to be more specific is an element I can use for grouping a set of other elements, without effecting their layout. The only thing it should do besides giving a nicer XAML by grouping related elements in their own parent tag is to propagate ambient properties such as DataContext. It should be a purely logical element without any visual. Is there something in WPF/XAML intended to be used like this?

3 Answers

Visual Studio 2019 contains a snippet for collapsible region tags. You can access this by typing #region and hitting tab twice.

It enters the following lines of code:

<!--#region MyRegion-->
<MyComponent />
<MyComponent />
<!--#endregion-->

It sounds like this is the tag you were looking for. As it is a comment tag, it doesn't allow any special interaction, so it won't propagate ambient properties unfortunately.

It does allow you to collapse the region in VS though.

Related