1
我有一個GridControl,我使用一些單元格內的幾個按鈕進行單元編輯。如何在DevExpress GridControl中綁定實際的主題名稱CellTemplate
這與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: 'Binding'不能在'ThemeName' 屬性中設置'ButtonsTh' emeKeyExtension」。 「綁定」只能在DependencyObject的DependencyProperty上設置爲 。
我該怎麼辦?