XAML Control.CornerRadius

By Fons Sonnemans, posted on
8033 Views

I'm in the process of learning the new Windows SDK Preview. Yesterday I wrote a blog about the new AppBarElementContainer. Today's subject is the new CornerRadius property of the Control class. Until now most input controls where rectangular. Now they can have rounded corners.

Demo

I have created a small demo page in which I placed a few input controls in a StackPanel. For all controls I have set the CornerRadius to 8.

<Page x:Class="App2.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:App2"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid>
        <StackPanel HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Spacing="8">
            <Button Content="Hello"
                    HorizontalAlignment="Stretch"
                    CornerRadius="8"
                    FontSize="20"
                    Margin="0,0,0,0"
                    VerticalAlignment="Center" />
            <TextBox Text="World"
                     CornerRadius="8" />
            <PasswordBox CornerRadius="8" />
            <ComboBox SelectedIndex="0"
                      HorizontalAlignment="Stretch"
                      CornerRadius="8">
                <ComboBoxItem Content="A" />
                <ComboBoxItem Content="B" />
                <ComboBoxItem Content="C" />
            </ComboBox>
            <TimePicker CornerRadius="8" />
        </StackPanel>
    </Grid>
</Page>

this results in the following output. The Button, TextBox, PasswordBox and ComboBox have rounded corners. Unfortunately the TimePicker does not. I hope it will be fixed before it released.

The focus rectangle of a Button is also still rectangular. I expect that will stay like this.

Closure

The CornerRadius is a nice new feature. I will maybe use it a one of my games. Probably not in a LOB app.

Fons

All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.

Leave a comment

Blog comments

0 responses