Hi,
I am trying to customize column header using style. I want to put button for filter in the column header. But the the column default style must be maintained as such. So I tried doing in the below mentioned way:
<Style TargetType="{x:Type igDP:LabelPresenter}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:LabelPresenter}">
<Grid>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
but when this style is applied to LabelPresenter i am loosing the default look for Column. I mean I am not able to view "sorting" icon which appears bydefault in the column though sorting functionality is working fine.
Please need help for this.
Thanks,
Sejal
Hello Dinesh,
Could you please be more specific what do you mean by "xyz line of code"?
Looking forward fro your reply.
Please can you tell me where to put xyz line of code withing default labelpreseneter templage because there are two grids and one of grid contain contentpresenter. please give example.
All,
I have pasted the default LabelPresenter Style in my resources area for testing. It works as formatted (I think) but hides the summation symbol I normally see on the header. Any idea what snippit controls the visualization of the summation symbol?
Glenn
Yes, thanks temp0 for the additoinal information - that is exacty what I meant originally. This is one of the reasons we consider default templates as part of our core product and ship them in the package - so you can easily start from them and modify / add your new functionality per your requirements.
I also mentioned Snoop and Mole - two great tools which can help you see the Visual Tree of the control - much helpful when you need to override styles / templates.
When you're creating a new template for a complex control (like parts of the XamDataGrid), the best way is to copy the original template (the entire thing in the post above) completely into your code and then add/edit whatever you want into that. This way, you will know without a doubt that no functionality you expect to have (like the sort indicator) will disappear.
So step by step instructions:
Where you've created your custom template in your xaml, replace it with the supplied LabelPresenter template above (true, it's a lot of code but at least it's complete). Then take your custom button in your custom template and paste it into the grid in the new template. You may have to experiment with where you put it but that's all you have to do.