Error setting property of local class name in WPF DesignData file

I have this DesignData file (compilation type set to DesignData) in a XAML file:

<local:FooModel xmlns:local="clr-namespace:MyProject" 
    Name="Sample" FullPath="C:/www" />

      

I have a FooModel

class inside a namespace MyProject

with these two properties. I am getting the Name property in XAML highlighted in red and this message:

Error 1 Because "microsoft.expression.markup.semantics.metadata.reflectiontypenode" is implemented in the same assembly, you must set the x: Name attribute and not the microsoft.expression.markup.semantics.metadata.ReflectionPropertyNode attribute.

I think the property is being Name

confused with something else. I mean a property of my class FooModel

and not something else. I am not getting warnings for FullPath

.

+3


source to share


2 answers


There is no way to reproduce this. Have a similar DesignData file, no problem including the Name property. You have no typo. The User Tool and User Namespace check are empty. I also suspect you have a strange build in your References list. Where did you get MS.Internal.Design ...? (was the project created in Blend?). In a standard VS generated project, this namespace does not appear on any of my assemblies. Check which assembly implements this namespace and try to remove it from the reference list.



+2


source


I met the same error. The error disappears for a while after repairing the solution, but it appears after opening the corresponding DesignData file in Visual Studio (VS Professional, version 11.0.51106.01 Update 1).

I tried to remove the referenced assemblies and clear the Custom Tool and Custom Namespace values ​​for this DesignData file. None of this worked. Pressing F12 in the xaml file doesn't divide anywhere, it only works for .cs files for me.

My decision



I got rid of this annoying error by specifying the full namespace: formname.propertyname in a separate xml element dedicated to it (instead of referencing it in the xml attribute of the parent class). In your case, this would mean:

<local:FooModel xmlns:local="clr-namespace:MyProject" FullPath="C:/www" >
    <local:FooModel.Name>Sample</local:FooModel.Name>
</local:FooModel>

      

0


source







All Articles