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


This content was proof-read by Grammarly. You can Try Grammary for FREE

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.


Are you a .NET Developer planning to integrate GraphQL for .NET in your Application? Check out this book
<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
%d bloggers like this: