我正在使用 Microsoft.Windows.Controls.Ribbon。
我想在我的功能区中有一个带有图片按钮的动态组合框。
如果我直接在 xaml 中执行此操作,我会得到我想要的:
<ribbon:RibbonComboBox
SelectionBoxWidth="62"
VerticalAlignment="Center"
>
<ribbon:RibbonGallery SelectedValue="0"
SelectedValuePath="Content"
MaxColumnCount="1">
<ribbon:RibbonGalleryCategory>
<ribbon:RibbonButton Label="Histo" HorizontalContentAlignment="Stretch"
Command="{Binding NewHistogrammCommand}"
SmallImageSource="/Test;component/Resourcen/Histogramm32.png"
LargeImageSource="/Test;component/Resourcen/Histogramm32.png" />
<ribbon:RibbonButton Label="3D" HorizontalContentAlignment="Stretch"
Command="{Binding NewDreiDCommand}"
SmallImageSource="/Test;component/Resourcen/DreiD32.png"
LargeImageSource="/Test;component/Resourcen/DreiD32.png" />
</ribbon:RibbonGalleryCategory>
</ribbon:RibbonGallery>
</ribbon:RibbonComboBox>
但是,如果我尝试通过这种方式绑定到集合来做到这一点:
<ribbon:RibbonComboBox
SelectionBoxWidth="62"
VerticalAlignment="Center"
IsEditable="True" >
<ribbon:RibbonGallery
MaxColumnCount="1">
<ribbon:RibbonGalleryCategory ItemsSource="{Binding LayoutContentTypeList, ElementName=mainWindow}">
<ribbon:RibbonGalleryCategory.ItemTemplate>
<DataTemplate>
<ribbon:RibbonButton Label="{Binding Header}" HorizontalContentAlignment="Stretch"
Command="{Binding Command}"
CommandParameter="{Binding CommandParameter}"
SmallImageSource="{Binding ImageSource}"
LargeImageSource="{Binding ImageSource}" />
</DataTemplate>
</ribbon:RibbonGalleryCategory.ItemTemplate>
</ribbon:RibbonGalleryCategory>
</ribbon:RibbonGallery>
</ribbon:RibbonComboBox>
我明白了
System.Windows.Data 错误:40:BindingExpression 路径错误:在“对象”“ContentPresenter”(名称=“”)上找不到“IsDropDownOpen”属性。绑定表达式:路径=IsDropDownOpen;DataItem='ContentPresenter' (Name=''); 目标元素是'RibbonButton'(名称='');目标属性是“NoTarget”(类型“对象”)
按钮可以正常工作,但如何解决此绑定错误?