这是一个非常狭隘的问题,我对发布它犹豫不决。
我在Grid
的资源中定义了一些虚拟数据,以便能够看到我的控件是如何呈现的。
<local:Team x:Key="DummyTeam">
<local:Team.Members>
<local:TeamMember Name="Edeax" Delay="3" />
<local:TeamMember Name="Neled" Delay="3" />
</local:Team.Members>
</local:Team>
一个有趣的是我想要定义'TeamMember'的属性'Name',因为它是XAML中常用的属性,Visual Studio会抱怨以下内容:
'Microsoft.VisualStudio.DesignTools.Xaml.LanguageService.Semantics.Metadata.ReflectionTypeNode' is implemented in the same assembly, you must set the x:Name attribute rather than the Microsoft.VisualStudio.DesignTools.Xaml.LanguageService.Semantics.Metadata.ReflectionPropertyNode attribute.
它编译并正常工作,但是,如何在XAML中正确设置Name
属性?
答案 0 :(得分:1)
简单 - 转换为嵌套参数,例如:
<local:TeamMember Delay="3" >
<local:TeamMember.Name>Edeax</local:TeamMember.Name>
</local:TeamMember>