我有一个 GridControl,我在单元格内使用一些按钮进行单元格编辑。
这是一个带有 3 个按钮的示例列:
xmlns:dxet="http://schemas.devexpress.com/winfx/2008/xaml/editors/themekeys"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:my="clr-namespace:MyProject.DevExpress.View"
<dxg:GridColumn Width="Auto"
AllowEditing="False"
AutoFilterCondition="Default"
FieldName="Information"
Header="Info"
ShowInColumnChooser="False"
VisibleIndex="1">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxe:ButtonEdit Name="PART_Editor" AllowDefaultButton="False">
<dxe:ButtonEdit.Buttons>
<!-- Button Action 1 -->
<my:ButtonInfoCustom Tag="Info1">
<my:ButtonInfoCustom.Template>
<DataTemplate>
<Button x:Name="PART_Item"
Height="Auto"
Content="{Binding DataContext.RowData.Row.InfoName}"
Style="{DynamicResource {dxet:ButtonsThemeKey ResourceKey=ButtonStyle,
ThemeName=DeepBlue}}"
ToolTip="{Binding DataContext.RowData.Row.CustomTooltip}" />
</DataTemplate>
</my:ButtonInfoCustom.Template>
</my:ButtonInfoCustom>
<!-- Button Action 2 -->
<my:ButtonInfoCustom Tag="Info2">
...
问题是主题。
如果我明确设置主题名称,它可以正常工作:
Style="{DynamicResource {dxet:ButtonsThemeKey ResourceKey=ButtonStyle, ThemeName=DeepBlue}}"
如果我尝试绑定:
Style="{DynamicResource {dxet:ButtonsThemeKey ResourceKey=ButtonStyle, ThemeName={Binding ThemeToUse}}}"
我明白了:
XamlParseException:无法在“ButtonsThemeKeyExtension”类型的“ThemeName”属性上设置“绑定”。只能在 DependencyObject 的 DependencyProperty 上设置“绑定”。
我应该怎么办?