Is there any simple way to add hyperlinks to PivotHeaderCell. I noticed that there is no direct way to add one.
I am using WPF 11.1
Thanks
Sangeetha
Hi,
there is ColumnHeaderStyle property for XamPivotGrid which allows you to restyle PivotColumnHeaderCellControl. There is such property and for rows.
Hope that this can help you.
Regards,
Dimitrina
Hello Sangeetha,
To add the hyperlinks in the rowheaders for example you can retemplate its default style. You can find the default styles installed on your computer in the file C:\Program Files (x86)\Infragistics\NetAdvantage 2011.1\WPF DV\DefaultStyles\XamPivotGrid\Classic.xaml . I believe that you can modify the ContentTemplate for the ContentPresenter named “HeaderPresenter” like this:
<DataTemplate x:Key="SummaryValueKey">
<StackPanel Orientation="Horizontal">
<TextBlock >
<Hyperlink>
<TextBlock Text="{Binding}"/>
</Hyperlink>
</TextBlock>
</StackPanel>
</DataTemplate>
Please find the attached sample where I show you this possible approach to achieve the desired functionality. I placed the modified default styles in the App.xaml file.
If you need any further assistance on this please do not heasitate to ask.
Thank You both for your prompt reply,
I am new to WPF so am trying to understand how it all works, especially applying the styles.
How can I apply Classic.xaml to my pivot grid by referencing it (rather than modifying it and adding it in App.xml), and then adding a setter property inline which sets the Row/Col Header Template for only certain headers. For example for all row headers at a particular level in the hierarchy. In my DataTable I have a column called Index.This column could be a row header or column header. I want all values of this column only to show hyperlink.
Hello ,
If you want to add the style only for the cell of one of the column/ rows you can set the style I provided for a single cell instead for the whole XamPivotGrid. You can try modifying the sample I sent by adding the following:
bool load = false;
private void pivotGrid_LayoutLoaded(object sender, EventArgs e)
{
load = true;
}
private void pivotGrid_LayoutUpdated(object sender, EventArgs e)
if (load)
foreach (PivotHeaderCell rc in pivotGrid.GridLayout.RowHeaderCells)
if(rc.Member.LevelName=="Partner name"&& rc.Control!=null)
rc.Control.Style = TryFindResource("RowStyle") as Style;
This will set the heads only for the level “Partner name” to look like a hyperlinks. If you drop any other dimension in the row collection you will notice that the style won’t apply for it. By setting the similar code you can provide the same functionality for the column headers.
Also the Classic.xaml file which I show you is simply copy of the original templates used in the XamPivotGrid assemblies and it is not referenced directly. If you want to change the design of the control you can use the public properties that it provides or to retemplate the default templates. I used the second approach and in order to prevent the XamPivotGrid of losing functionality while I copied its default templates(form the file Classic.xaml) and I modified only the parts of the default one that I wanted to change. The file itself doesn’t have any connection with our control so modifying it on place will not cause any changes in XamPivotGrid.
If you have any further questions or concerns, please do not hesitate to ask.
Great Thanks. Works perfect.
My only problem is how can I add hyperlink click event to it. I don't want to add any url. I want to execute a local function. How can I do this?
I set a Relative Source and wrote an click event to my Hyperlink object and it works great now. Here is how I did it.
<Hyperlink Click="Hyperlink_Click" Command="{Binding DataContext.MyCommand, RelativeSource={ RelativeSource FindAncestor, AncestorType ={x:Type ig:XamPivotGrid}}}"> <TextBlock Text="{Binding}" /> </Hyperlink>