Home > DeveloperSection > Interviews > What is the difference between X:name and x:key?

Posted on    October-14-2013 8:33 AM

 1 Answer(s)
  2028  View(s)
Rate this:

jacob rasel
jacob rasel

Total Post:23

Posted on    October-14-2013 12:00 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick