GillesDV
GillesDV

Reputation: 293

Stick UI element in top right corner in an UWP window

I googled this, but I couldn't find an answer yet, so I figured I'd ask the question here. I'm creating a fairly simple UWP app. In one of the pages, I want to have a large + button in the top right corner, to add an object.

I'm currently using a RelativePanel, but I can't find how I can stick my plus button to the corner of the entire frame. In most cases, I could use the relative layout in order to do something like RelativePanel.LeftOf="txtTest". But I can't do this now, since the entire page isn't something I can refer to.

Below is the current xaml code for the Button. Anybody know how I can stick it to the top right corner, no matter what the screen size is, including resizing? Now that I think about it, I might have to use something else than RelativePanel.

<Button x:Name="btnAddToDo" Content="+" 
           HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,-350,-10"/>

Upvotes: 0

Views: 1033

Answers (1)

Igor Ralic
Igor Ralic

Reputation: 15006

RelativePanel is fine, as long as it stretches inside of the window/page.

<Button x:Name="btnAddToDo" 
        Content="+"
        RelativePanel.AlignTopWithPanel="True"
        RelativePanel.AlignRightWithPanel="True"/>

Upvotes: 1

Related Questions