1
我试图绑定一个RibbonGroup和一对夫妇RibbonButtons到我视图模型与下面的XAML代码:ItemContainerStyle为RibbonGroup
<Style TargetType="{x:Type ribbon:RibbonGroup}" x:Key="RibbonGroupStyle">
<Setter Property="Header" Value="{Binding Header}" />
<Setter Property="ItemContainerStyle" Value="{DynamicResource RibbonButtonStyle}" />
<Setter Property="ItemsSource" Value="{Binding Buttons}" />
</Style>
<Style TargetType="{x:Type ribbon:RibbonButton}" x:Key="RibbonButtonStyle">
<Setter Property="Label" Value="{Binding Header}" />
</Style>
这给了我下面的错误,我能理解,但我该怎么办正确绑定RibbonButton的标签到我的viewmodel?
A style intended for type 'RibbonButton' cannot be applied to type 'RibbonControl'.
好了,但将最好的办法是将它应用到每个按钮是什么? – Chrille 2013-04-08 12:58:39
如果你不指定Style键,那么它应该适用于这种类型的所有控件。 – icebat 2013-04-08 12:59:42
所以我意识到问题是,当我将我的功能区按钮视图模型对象的列表绑定到我的RibbonGroup的ItemsSource时,它们被创建为RibbonControls而不是RibbonButtons,我如何控制它?我想我在我的约束中失去了一些基本的东西。 – Chrille 2013-04-09 09:06:59