wpf - How to change text of a DataGridColumnHeader -
i have following text column defined, , want programmatically replace text in 3 text blocks. appreciated.
<datagridtextcolumn x:uid="expiration_datagridtextcolumn" binding="{binding expiration}"> <datagridcolumn.headerstyle> <style targettype="datagridcolumnheader" basedon="{staticresource threelinecolumnheaderstyle}"> <setter property="contenttemplate"> <setter.value> <datatemplate> <stackpanel> <textblock x:uid="expiration_header_line1" text="" horizontalalignment="center" /> <textblock x:uid="expiration_header_line2" text="expriation" horizontalalignment="center" /> <textblock x:uid="expiration_header_line3" text="" horizontalalignment="center" /> </stackpanel> </datatemplate> </setter.value> </setter> </style> </datagridcolumn.headerstyle> </datagridtextcolumn>
you can bind text of vm properties using relative source binding.
you should override headertemplate rather style,
<datagridtextcolumn x:uid="expiration_datagridtextcolumn" binding="{binding expiration}"> <datagridcolumn.headertemplate> <datatemplate> <textblock text="yourcolumnname" horizontalalignment="center"></textblock> </datatemplate> </datagridcolumn.headertemplate> </datagridtextcolumn>
Comments
Post a Comment