0

We are using Microsoft ribbon control library for .Net 4.0.

I was trying to bind RibbonGroup.GroupSizeDefinitions to a property of the ViewModel. If we declare the binding in Xaml as follows it is working fine.

<ribbon:RibbonGroup Header="Group1" GroupSizeDefinitions="{Binding GroupDefinitions}" />

However if I set this using a Style this is not working.

<Style TargetType="{x:Type ribbon:RibbonGroup}" BasedOn="{StaticResource {x:Type ribbon:RibbonGroup}}">
    <Setter Property="GroupSizeDefinitions" Value="{Binding GroupDefinitions}" />
</Style>

How can I bind this to the View Model ?

Thanks.

4

1 回答 1

1

最后我能够让它工作。

我添加了一个附加属性并绑定到视图模型中的集合。然后在附加属性更改回调时,创建一个新的 RibbonGroupSizeDefinitionBaseCollection 并添加集合的项目。然后将新的 RibbonGroupSizeDefinitionBaseCollection 分配给 RibbonGroup.GroupSizeDefinitions 属性。

于 2013-10-07T10:35:10.003 回答