How to embed Rectangle inside a Button in Windows Store App using C#?

Published on July 24, 2015 by abundantcode

Filed under XAML

Last modified July 24, 2015

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 4 (3 votes)

This article have been viewed 6129 times

Below is a sample code demonstrating how to embed a Rectangle inside a Button in Windows Store App using C#?.

How to embed Rectangle inside a Button in Windows Store App using C#?

Windows.UI.Xaml.Controls.Button ACBtn = new Windows.UI.Xaml.Controls.Button { Width=200 , Height = 100 };
Windows.UI.Xaml.Shapes.Rectangle rectangle1 = new Windows.UI.Xaml.Shapes.Rectangle() { Width = 175, Height = 75, Fill = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.AliceBlue) };
ACBtn.Content = rectangle1;
// Panel is a Container of type Grid
Panel.Children.Add(ACBtn);

The Xaml page with the Grid named “Panel” looks like the one shown below.

<Page
    x:Class="UniversalApp1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UniversalApp1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid x:Name="Panel"  Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        
    </Grid>
</Page>

 

image

Leave a Comment


x

You might be Interested in these Posts

How to delete user account from command line in Windows 10 ?

You can delete a user account from command line in Windows 10 using the net user command and specify...

How to add new user account from command line in Windows 10 ?

You can add a new user account in Windows 10 using command prompt using the net user command and pas...

How to open display settings from command line in Windows 10 ?

The display properties can be found in the settings app in Windows 10 which lets the users to config...