avaloniauiavalonia

How to create Avalonia controls that "float" aligned bottom right above other controls


I'm porting the following Windows Forms view to Avalonia:

enter image description here

The Loading... (56%) is a Label control that has been added to the Form with the Anchor property set to Bottom, Right, so it will stay in the bottom right as the form is resized. Its Z-order is such that it always appears in front of the "Lorem ipsum" text box in the background. Once loading is completed the label is hidden.

How do I port this to Avalonia? I was looking at the Canvas class which allows full freedom of placement, but which puts a burden on the programmer to update the Canvas.Left etc properties accurately. Is there a simpler way to accomplish this?


Solution

  • Consulting with the Avalonia dev team (and with thanks to @MikeCodesDotNET at Github.com), the following answer was provided. It works just as I wanted:

    <Panel>
            <TextBox Text="{Binding Greeting}"
                       HorizontalAlignment="Stretch" 
                       VerticalAlignment="Stretch"
                       TextWrapping="Wrap"/>
            
            <TextBlock Text="Loading... (56%)" 
                       Background="Blue"
                       Foreground="White"
                       Padding="10"
                       VerticalAlignment="Bottom"
                       HorizontalAlignment="Right"/>
     </Panel>