tags:

views:

355

answers:

3

Possible Duplicate:
In WPF, what are the differences between the x:Name and Name attributes?

Hi,

I just stepped into the WPF and I read various texts about it. But what I don't understand is the difference between 'Name' and 'x:Name'? In most cases I can use the 'Name' and it's working ok, but in plenty tutorials is the second variant used instead (the 'x:Name').

Why?

Thanks

A: 

They refer to the same thing, but you have to use the x: prefix when defining a UserControl.

Daniel Earwicker
+1  A: 

FrameworkElement and FrameworkContentElement both specify the Name property and since most elements you use will derive from these types the x: namespace isn't required. Either is acceptable (on objects that support simply Name) but you cannot use both at the same time.

Quintin Robinson
A: 

The 'x:' part of the name in the XAML code is the reference to the XML Namespace the property is part of. It is possible that some element could have more than one namespace, and each namespace has a seperate 'name' property. In that case, you'd have to use x:Name and otherNS:Name to reference them properly.

Justin Niessner