【发布时间】:2013-10-10 03:43:34
【问题描述】:
我在控件的资源中声明了以下标记:
<conv:ActionItemToBooleanConverter x:Key="ActionItemToBooleanConverter" />
<Style TargetType="{x:Type ListBox}">
<Setter Property="ListBox.ItemTemplate">
<Setter.Value>
<DataTemplate>
<RadioButton Content="Foo2"
GroupName="FOo"
IsChecked="{Binding CurrentProcessPoint, Converter={StaticResource ActionItemToBooleanConverter}, Mode=TwoWay}"
Style="{StaticResource {x:Type ToggleButton}}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
对于 RadioButton,当我在 IsChecked 属性上引入 Converter={StaticResource ActionItemToBooleanConverter} 时,它突然给我的 Style="{StaticResource {x:Type ToggleButton}}" 带来了问题。样式下方出现蓝色波浪线,并显示“资源 {x:Type ToggleButton} 无法解析”。
为什么会这样?为我的 Converter 引入 StaticResource 导致我无法将 RadioButton 设置为 ToggleButton 的原因是什么?
我可以添加/修复什么来解决冲突?
谢谢
【问题讨论】:
-
它在运行时工作吗?
-
在 VS 2012 中,有时设计器会显示错误,而实际上并没有。有时这是一种皇家的痛苦。如果代码在您按 F5 时编译并运行,那就很好。
-
@Omribitan 它确实在运行时工作。因此,如果它是 VS2012 设计时问题,那就这样吧。我只是觉得它很奇怪,并想知道为什么会发生这些错误。感谢您的评论。
-
如果关闭 XAML,错误是否仍然存在?