-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
I have use case for x:Reference markup extension when used in Avalonia for defining docking layouts using xaml.
Example:
<Dock xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:Demo.ViewModels;assembly=Demo"
ActiveLayout="{x:Reference layout1}">
<Dock.Items>
<vm:Item1ViewModel x:Name="item1"/>
<vm:Item2ViewModel x:Name="item2"/>
<vm:Item3ViewModel x:Name="item3"/>
<Dock.Items>
<Dock.Layouts>
<Layout x:Name="layout1">
<x:Reference Name="item1"/>
<x:Reference Name="item2"/>
</Layout>
<Layout x:Name="layout2">
<x:Reference Name="item1"/>
<x:Reference Name="item2"/>
<x:Reference Name="item3"/>
</Layout>
</Dock.Layouts>
</Dock>In my example I have two separate instances of Layout object (layout1 and layout2) but both reference same child items. This allows switching layouts during runtime (by setting ActiveLayout property) while items retain their state.
Dock:
Docs:
https://docs.microsoft.com/en-us/dotnet/framework/xaml-services/x-reference-markup-extension
Metadata
Metadata
Assignees
Labels
No labels