Creating Button in XAML in WPF and Windows Store App

Below is a sample Xaml code that is used to create a button in WPF and Windows Store App.

<Button xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Content="Abundantcode Button"/>

The Button can also be created in the code behind of your Xaml page in C# . You would generally see the difference in the namespace based on the UI framework.

For example , if you want to create a button in C# in your WPF application , you would use the System.Windows.Controls namespace as shown below.

System.Windows.Controls.Button btn1 = new System.Windows.Controls.Button();
btn1.Content = "Abundantcode Button";

If you are using the Windows Store or Windows Phone App , you can use the button class that is defined in the namespace Windows.UI.Xaml.Controls.

Windows.UI.Xaml.Controls.Button btn1 = new Windows.UI.Xaml.Controls.Button();
btn1.Content = "Abundantcode Button";
Tags :

Leave Your Comment

Liked this content?. Please spread the word :)