我有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>
我可以使用Image
添加DataTemplate
,但这些图片是不同的资源:
<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
?
答案 0 :(得分: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>