Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone
I have a datagrid in wpf .I have a button inside datagrid.I want to set an image on button how i set the image
plz help...

the code is
<DataGridTemplateColumn Header="Delete" Width="60">
     <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
           <Button Content="Delete"    Click="DeleteButton_Click"  ></Button>
        </DataTemplate>
      </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>




how to set image on delete button


Thanks
Posted
Updated 9-Jul-13 20:57pm
v3

1 solution

HTML
<datagridtemplatecolumn header="Delete">
                              Width="60">
          <datagridtemplatecolumn.celltemplate>
              <datatemplate>
                      <button content="Delete" Click="DeleteButton_Click" >
                          <button.template>
                              <controltemplate>
                                  <border horizontalalignment="Center">
                                          VerticalAlignment="Center">
                                      <image source="ImagePath">
                                             Width="16"
                                             Height="16" />
                                  </image></border>
                              </controltemplate>
                          </button.template>
                      </button>
                  </datatemplate>
          </datagridtemplatecolumn.celltemplate>
      </datagridtemplatecolumn>
 
Share this answer
 
v2
Comments
ErBhati 10-Jul-13 3:52am    
Thanks but i solved it by another way
Sushil Mate 10-Jul-13 3:53am    
would like to share with us.
ErBhati 10-Jul-13 5:56am    
<datagridtemplatecolumn header="Delete" canuserresize="False" minwidth="25">
<datagridtemplatecolumn.celltemplate>
<datatemplate>
<Button Click="DeleteButton_Click" >
<Button.Content>
<Image Source="..\Images\delete.gif"></Image>
</Button.Content>
</Button>


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900