Share your content and reach out to more developers by submitting them at Abundantcode.com - Developer Community Site

Creating a Button in UWP app by specifying the namespace as one of the attributes of button

You can add a button in your Universal Windows Platform (UWP) app by simply adding the Button tag in the Xaml page. You will notice that the Namespace "http://schemas.microsoft.com/winfx/2006/xaml/presentation" is already referred in the Page element.

<Page
    x:Class="ACUWPApp.MainPage"  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />

You can add a button in the UWP app page by specifying the namespace as one of the attributes of button instead of specifying it at the page level. Below is a sample code snippet demonstrating how to do it.

 <ACNamespace:Button xmlns:ACNamespace="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Content="Click Me" Height="200" Width="200"/>

For readability , it is better to define the commonly used namespace (XML namespace) at the Page level so that this need not be repeated everytime.

Tags :

Leave Your Comment