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>
Leave a Reply