如何将 DevExpress 图标库中的图标添加到 ButtonEdit

How to add icon from DevExpress Icon Library to a ButtonEdit

我有以下 ButtonEdit 模板:

<dxg:GridControl.Columns>
            <dxg:GridColumn Width="100"
                            AllowEditing="False"
                            AutoFilterCondition="Default"
                            FieldName="Information"
                            Header="Info"
                            ShowInColumnChooser="False"
                            SortOrder="Ascending"
                            VisibleIndex="0">
            <dxg:GridColumn.CellTemplate>
                    <DataTemplate>
                        <dxe:ButtonEdit x:Name="PART_Editor" AllowDefaultButton="False">
                            <my:ButtonInfoCustom ContentTemplate="{StaticResource MyDataTemplate}" 
                                            DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type dxg:GridControl}}}"
                                                  GlyphKind="Custom"
                                                  IsEnabled="{Binding}"
                                                  Tag="Info1"
                                                  ToolTip="Action 1" />
                        </dxe:ButtonEdit>
                    </DataTemplate>

我可以用 DataTemplate 添加 Image 它,但这些图像是单独的资源:

<DataTemplate x:Key="MyDataTemplate">
        <Image Source="/Assembly1;component/Icons/main_icon.png" />
</DataTemplate>

我打算像这样使用图标库中的 Glyph

<dx:SimpleButton x:Name="btn1"
                     Width="Auto"
                     Height="25"
                     HorizontalAlignment="Left"
                     Content="Add info"
                     Glyph="{dx:DXImageOffice2013 Image=Add_16x16.png}" />

如何为 ButtonEdit 添加 Glyph

嗯,你可以把 ContentTemplate 改成 DataTemplate 然后简单地放一个控件用 Glyph 属性 变成:

<dxe:ButtonEdit Name="PART_Editor" AllowDefaultButton="False">
       <my:ButtonInfoCustom>
           <my:ButtonInfoCustom.Template>
                <DataTemplate>
                    <dx:SimpleButton x:Name="PART_Item" Width="Auto" Height="Auto" 
                             Glyph="{dx:DXImageOffice2013 Image=Cancel_16x16.png}"  
                             IsEnabled="{Binding IsThisButtonEnabled}"
                             Tag="Info1" ToolTip="Action 1" />
                </DataTemplate>
           </my:ButtonInfoCustom.Template>
       </my:ButtonInfoCustom>
 </dxe:ButtonEdit>