Action Controls

As for you have learned more about how to incorporate the various layout controls in XAML. Now you should move towards more controls that users can interact with, such as the Button, TextBlock, TextBox, ComboBox, and much more. All the controls you need are available in WinRT. If you come from an ASP.NET background, you must be familiar with the concept of a code behind page. The code behind page is where you put event handlers for the several interactive controls and put the logic essential to handle those controls. In XAML you also have the same concept to place your control event handling code. For now we’ll look at the default behavior of interacting with XAML controls using the code behind page and see what types of interactive controls are available from WinRT.


TextBlock control is the most basic control offered in XAML. It has the only purpose to display basic text on the screen. It is equivalent of a plain <div> tag or Label control in ASP.NET. Although most XAML controls depend on on the Content property to define what appears, the TextBlock control uses a Text property instead because the only valid output for this control is text. Here is the XAML code for declaring a TextBlock:

<TextBlock Text="This is some text" />


The TextBox control is an input control that enables you to detent keyed input from the user. Like the TextBlock this control uses the Text property instead of the Content property to display entered text. Here is the XAML code to create a basic TextBox control:

       <TextBox Text="" />


The Button control permits you to click or touch to perform an action. When creating a Button control in XAML, you can use the
Content property to define what text appears in the Button. The following code declares a basic XAML Button control:

        <Button x: Name="StandardButton" Content="Login" />

The main purpose of a Button control is to perform some kind of user interface action. You can handle the Click event of the Button control and perform some logic in the code behind event handler. The code for the Click event is as follows:

         private void Login_Click(object sender, RoutedEventArgs e)
         // your logic comes here
Action Controls Action Controls Reviewed by Afsar Murad on 22:07 Rating: 5
Powered by Blogger.