开发者

Bind RibbonComboBox.SelectionBoxItem

开发者 https://www.devze.com 2023-03-20 05:37 出处:网络
I\'m trying to bind the item selected in a RibbonComboBox to a property of an object.The problem I\'m encountering is that the RibbonComboBox.SelectionBoxItem only provides a get accessor; therefore,

I'm trying to bind the item selected in a RibbonComboBox to a property of an object. The problem I'm encountering is that the RibbonComboBox.SelectionBoxItem only provides a get accessor; therefore, I cannot bind it to anything in the XAML.

Any i开发者_C百科deas how to bind the item to the property of an object? I could use a regular ComboBox is there another more appropriate control?

xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"

<ribbon:RibbonComboBox
    ItemsSource="{Binding Source={StaticResource CollectionOfPossibleChoices}}"/
    SelectionBoxItem="{Binding Path=PropertyToBindTo}"/> <!--Not valid-->


RibbonComboBox is unlike ComboBox (which i, also, find confusing). Try this;

<ribbon:RibbonComboBox>
    <ribbon:RibbonGallery SelectedItem="{Binding Path=PropertyToBindTo}">
        <ribbon:RibbonGalleryCategory ItemsSource="{Binding Source={StaticResource CollectionOfPossibleChoices}}" />
    </ribbon:RibbonGallery>
</ribbon:RibbonComboBox>

MSDN Reference

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号