tags:

views:

63

answers:

2

ReSharper's complaining about some of my XAML with the following error:

'Name' attribute is not allowed here because type 'FlashingTextBlock' is implemented in the same project. Use 'x:Name' instead

What's the problem here? Should I do what it says?

+2  A: 

See an excellent explanations in this answer, and decide for your own ;)

http://stackoverflow.com/questions/589874/in-wpf-what-are-the-differences-between-the-xname-and-name-attributes

Arcturus
Cool. So why is it a problem that it's implemented in the same project?
Roger Lipscombe
It isnt a problem.. simply put, x:Name makes your control available in the code behind as well.
Arcturus
Let me rephrase that: why does *ReSharper* think it's a problem that it's implemented in the same project?
Roger Lipscombe
A: 

Does FlashingTextBlock have a System.Windows.Markup.RuntimeNameProperty attribute?

According to "Windows Presentation Foundation Unleashed" by Adam Nathan:

... you can simply set its Name property to a string rather than use the x:Name syntax. You can use either mechanism, but you can't use both simultaneously.

richj
No, it doesn't have a `RuntimeNameProperty` attribute. It's a `UserControl`; presumably it inherits `Name` from `FrameworkElement`?
Roger Lipscombe
Yes - I found a reference here: http://msdn.microsoft.com/en-us/library/system.windows.markup.runtimenamepropertyattribute%28VS.85%29.aspx
richj

related questions