WHAT IS THE DIFFERENCE BETWEEN X:NAME AND X:KEY?

jacob rasel

Total Post:23

Points:115
Posted by  jacob rasel
WPF 
WPF
 2078  View(s)
Ratings:
Rate this:
  1. jacob rasel

    Post:23

    Points:115
    What is the difference between X:name and x:key?



    x:Key-X:Key identifies objects in resources section, can be accessed by resourceDictionary .x:key is used for items that are being added as values to a dictionary, most  for styles and other resources that are being added to a ResourceDictionary. When setting the x:Key attribute, there is actually no corresponding property on the object or even an attached dependency property being set. It is simply used by the XAML processor to know what key to use when calling Dictionary.Add.


    x:Name-X:name idetifies a UIElment in XAML Tree is a bit more complicated. x:Name- used to apply an associated name to an object (typically an object derived from FrameworkElement) within the scope of some parent element. This scope is called a "namescope" and the easiest way to think of it is to imagine a UserControl that contains a <TextBox x:Name="foo" />.

      Modified On Mar-15-2016 06:17:40 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!