1

我有一个 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 上设置“绑定”。

我应该怎么办?

4

1 回答 1

0

好吧,您不应该将任何主题名称放入您的 XAML 代码中。

相反,当他们考虑实际主题并相应地更改其外观时,请使用 DevExpress 内置控件。

检查此示例(我Style完全删除了标签并替换ButtonSimpleButton):

<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>
                                        <dx:SimpleButton x:Name="PART_Item"
                                                Height="Auto"
                                                Content="{Binding DataContext.RowData.Row.InfoName}"                                                                                                       ToolTip="{Binding DataContext.RowData.Row.CustomTooltip}" />
                                    </DataTemplate>
                                </my:ButtonInfoCustom.Template>
                            </my:ButtonInfoCustom>
                            <!--  Button Action 2  -->
                            <my:ButtonInfoCustom Tag="Info2">
    ...
于 2016-05-30T14:33:45.863 回答