How to add an image to a DataGridTemplateColumn he

2019-09-09 20:13发布

I have a Datagrid with some DataGridTemplateColumns. One of them is for the costs (see code below). The column heading is Costs. Now I want a image at the right side of the heading Costs. How can I do that?

<DataGrid     
        ItemsSource="{Binding AvailableNetworkInterfaces}"   
        SelectedItem="{Binding SelectedItemProperty}">

    <DataGrid.Columns>

    <DataGridTemplateColumn Header="Costs" Width="100" x:Name="ColumnCosts">
        <DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
                <TextBox Width="80" Text="{Binding Dollar, Mode=OneWay}"/>
            </DataTemplate>
        </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>

    </DataGrid.Columns>
</DataGrid>

1条回答
手持菜刀,她持情操
2楼-- · 2019-09-09 20:55
<DataGrid     
    ItemsSource="{Binding AvailableNetworkInterfaces}"   
    SelectedItem="{Binding SelectedItemProperty}">

<DataGrid.Columns>

<DataGridTemplateColumn Width="100" x:Name="ColumnCosts">
    <DataGridTemplateColumn.Header>
       <Stackpanel>
          <TextBlock Text="Costs"/>
          <Image Source="...\" />
       </Stackpanel>
    </DataGridTemplateColumn.Header
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <TextBox Width="80" Text="{Binding Dollar, Mode=OneWay}"/>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

</DataGrid.Columns>

查看更多
登录 后发表回答