Computer Magic Logo
The x:Name attribute

Tuesday, April 12, 2016

Published by Aristotelis Pitaridis

Every programming language use a property for the controls which is unique in the controls collection so that we will be able to reference it. In XAML we use the x:Name attribute name in order to give a unique name to a control.

<Label x:Name="MyLabel" Text="Hello World!" />

Now we can use in the code-behind file the nameĀ MyLabel in order to access the Label control.

MyLabel.Text = "Hello World!";