top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the Properties and Events in Windows phone application ?

+1 vote

Explain with example.

posted Dec 10, 2014 by Saravanan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Properties and events:

Every control can be customized in two ways: by setting properties and actions. Both are identified by attributes of the XAML tag, but they have two different purposes.

Properties are used to change the look or the behavior of the control. Usually, a property is simply set by assigning a value to the specific attribute.
For example, if we want to assign a value to the Text property of a TextBlock control, we can do it in the following way:

<TextBlock Text="This is a text block" /> 

There’s also an extended syntax that can be used in the case of a complex property that can’t be defined with a plain string. For example, if we need to set an image as a control’s background, we need to use the following code:

        <ImageBrush ImageSource="/Assets/Background.png" />

Complex properties are set by using a nested tag with the name of the control plus the name of the property, separated by a dot (to set the Background property of the Grid control, we use the Grid.Background syntax).

One important property that is shared by every control is x:Name, which is a string that univocally identifies the control in the page. You can’t have two controls with the same name in a single page. Setting this property is very important if you need to interact with the control in the code behind—you’ll be able to refer to it by using its name.


Events are a way to manage user interactions with the control. One of the most used is Tap, which is triggered when users tap the control.

<Button Tap="OnButtonClicked" /> 

When you define an action, Visual Studio will automatically prompt you to create an event handler, which is the method (declared in the code behind) that is executed when the event is triggered.

private void OnButtonClicked(object sender, GestureEventArgs e)
MessageBox.Show("Hello world");

In the previous example, we display the classic “Hello world” message to users when the button is pressed.

answer Dec 11, 2014 by Jdk
Similar Questions
+2 votes

I often see while developing phone app in grid they using Asterisk(*) and Auto , i cant identify its use any people pls kindly give some suggestions....

+1 vote

I am using Visual Studio 2013 for developing windows phone application how to test my application any one explain how can i achieve this... thanks in advance:)