【发布时间】:2014-03-13 01:20:59
【问题描述】:
在 WPF 中创建顶级菜单时,我使用了将 RadioButton 样式设置为 ToggleButton 的技巧,以获得“仅选择一个”效果。像这样:
<ItemsControl ItemsSource="{Binding ViewModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton Content="{Binding Key.Name}" GroupName="MenuButtonGroup"
Style="{StaticResource {x:Type ToggleButton}}" >
</RadioButton>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
它运行良好,并且符合我的预期。但 Visual Studio 将其注册为错误。
Style 属性带有蓝色下划线,给出的描述是资源“{x:Type ToggleButton}”无法解析。
这一切看起来都是光明正大的,但是把它放在我在 Visual Stuido 的错误列表中是非常令人恼火的。知道如何解决吗?
编辑:刚刚发现这个问题 -
The resource could not be resolved (VS 2010 RC)
这表明这是一个 VS 错误。有人证实这一点,或者知道解决办法吗?哪里有问题,还是很烦人!
【问题讨论】: