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
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>
I can write a hyperlink click event at
<Hyperlink Click="Hyperlink_Clicked">.
But the problem is I won't be able to get PivotHeaderCell from it. As i need to use this info to retrieve some info from the corresponding record.
Or should I write a Key_up event?
Please advise me as to the best way to write a click event in this case.
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?
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.
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.