0

我有以下模板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>

我可以添加ImageDataTemplate,但这些图像是单独的资源:

<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}" />

我怎么能添加Glyph一个ButtonEdit

4

1 回答 1

1

好吧,您可以将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>
于 2016-05-30T14:25:04.643 回答