我使用ReSharper的6.1.1,并具有在我的项目启用solution wide analysis一个错误显示出来:避免“目标式‘类型名称’是无法转换为基地System.String类型”
Target type 'CustomControls.XSButton' is not convertible to base type System.String
的代码编译并运行良好,因为WPF中的内置TypeConverter负责处理此问题,在ReSharper bug report中对此进行了简短描述。
请注意,XSButton
是在我的解决方案中的程序集中声明的 - 它不是内置类型的WPF。
这是在<Style>
标记处导致此错误的xaml代码。
<CustomControls:XSButton
Content="i" Grid.Column="2" Command="ApplicationCommands.Help"
Grid.Row="0" Grid.RowSpan="2" ToolTip="Show Help" Visibility="Collapsed">
<CustomControls:XSButton.Style>
<Style TargetType="{x:Type CustomControls:XSButton}">
<Setter Property="Height" Value="26"/>
<Setter Property="Width" Value="26"/>
<Setter Property="CornerRadius" Value="13"/>
</Style>
</CustomControls:XSButton.Style>
</CustomControls:XSButton>
有什么办法避免这种情况:
- 属性需要一个
System.String
等什么字符串字面量应该我取代类型实例与? - 有什么办法可以忽略这个ReSharper错误?
- 是否以任何方式到rearange xaml避免这个错误?例如。 se属性directl而不是使用setters?
编辑
只有在风格标签内同一类型的标签,在这种情况下出现的问题“富:酒吧”。请注意,我是开放式的,可以避免这种错误?也许完全重新安排xaml代码。
我alrady使用R#版本6.1.1。查看我更新的问题 – vidstige 2012-02-27 08:03:43
在此代码片段中,您使用了WPF内置类型,而我使用在我的程序集中声明的类型。 – vidstige 2012-02-27 08:05:46
@ContolFlow嗨,我添加了一些更多的信息。似乎它有可能避免这一些如何。就像不使用setters,但立即或somethig分配适当的... – vidstige 2012-02-28 09:11:27