Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 971015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:53:43+00:00 2026-05-16T02:53:43+00:00

I am new in Silverlight. When I add some control to my xaml file

  • 0

I am new in Silverlight.
When I add some control to my xaml file with Visual Studio it set controls name with Name property, but there is also x:Name.
Is there any difference and when to use each of them?
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:53:44+00:00Added an answer on May 16, 2026 at 2:53 am

    In Brief

    Yes there is a difference. The bottom line is that x:Name can be used on object elements that do not have Name properties of their own.

    A longer explanation

    You can only use Name on an element that represents an object that actually does have a Name property. For example anything that derives from FrameworkElement.

    The x:Name attribute may be placed on any element that represents an object regardless of whether that object actually has a Name property. If the object does have a Name property then the value of x:Name will be assigned to it hence you can’t have both x:Name and Name on the same element.

    When an object has a Name property or an x:Name property the value of that property is associated with the objects entry in the object tree. It is via the object tree that the FindName method of a FrameworkElement can find an object. FindName can find objects by name even if that object does not carry a Name property of its own since it uses the name recorded in the object tree.

    The autogenerated code for a UserControl will contain field definitions for any element that that has a Name or x:Name property. The InitialiseComponent method that is generated will use the FindName method to assign values to these fields.

    Example

    The above Xaml creates two fields LayoutRoot of type Grid and MyBrush of type SolidColorBrush. If you were to change x:Name="LayoutRoot" to Name="LayoutRoot" that would change nothing. Grid has a Name property. However try changing x:Name="MyBrush" to Name="MyBrush". That doesn’t work because SolidColorBrush doesn’t have a name property. With the above Xaml you can then do code like this:-

        public MainPage()
        {
            InitializeComponent();
            MyBrush.Color = Colors.LightGray;
        }
    

    Open the definition of InitializeComponent and take a look at the auto generated code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a new silverlight business application in visual studio. It auto generates
How do I get the Silverlight Add-On for Visual Studio 2010? And where can
I am creating a new Silverlight project in Visual Studio 2008 Sp1. Further creating
So I'm creating columns dynamically for a Grid layout in Silverlight (V3.0, C#): LayoutRoot.ColumnDefinitions.Add(new
I can create new Silverlight App with .NET RIA Services enabled. But when I
I'm new in Silverlight and i am doing some tests. With my current test
I'm automating UI tests to my Silverlight App and I'm using Visual Studio 2010
I am trying to populate a TreeView in silverlight, but I am having some
I'm an experienced developer, but new to Silverlight, Prism, MVVM and all related stuff,
I have inherited some Silverlight\WCF code and now need to implement some new features.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.