Hi,
I have a pivotTable where I want to see in Rows a Geography dimension p.e. Countries.
For each country that I see in these rows I want to have hidden in my tuple the longtitude and latitude.
Can I do this and if yes how?
In general can I have hidden values in tuples ? For example could I fill somehow the Tag property ?
Thank you,
Dimitris
You can store extra metadata as attached properties set to DataRow. What i mean.
1 Create Dummy class and register attached property for that class.
public class ExtendProp : DependencyObject { #region PivotPartType /// <summary> /// Identifies the <see cref="PivotPartType"/> dependency property /// </summary> public static readonly DependencyProperty PivotPartTypeProperty = DependencyProperty.RegisterAttached( "PivotPartType", typeof(int), typeof(ExtendProp), new PropertyMetadata(0, OnPivotPartTypeChanged)); /// <summary> /// Returns the value of PivotPartType attached property of a UIElement. /// </summary> /// <param name="obj">UIElement that this property is attached.</param> /// <returns>A value of the propery.</returns> public static int GetPivotPartType(DependencyObject obj) { return (int)obj.GetValue(PivotPartTypeProperty); } /// <summary> /// Sets the PivotPartType attached property to a UIElement. /// </summary> /// <param name="obj">The element to which the property is attached.</param> /// <param name="value">The value of the property.</param> public static void SetPivotPartType(DependencyObject obj, int value) { obj.SetValue(PivotPartTypeProperty, value); } private static void OnPivotPartTypeChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) { } #endregion // PivotPartType }
2. Attach value to row
pivotGrid.LayoutLoaded += (s, e) => { ExtendProp.SetPivotPartType(pivotGrid.DataRows[0], 9); };
3 Read value
int i = (int)ExtendProp.GetPivotPartType(pivotGrid.DataRows[0]);
4 DataRow has Tuple property, so you can easy reach the tuple.
this.pivotGrid.DataRows[0].Tuple
In sample property is from int type, but it can be from any type in .NET
Todor
Hi
The solution above will not work for Rows because they are not DependencyObject. It will work for columns.
Another possible solution can be to use Tag property of Tuple's members
(pivotGrid.DataSource.Result.RowAxis.Tuples[0].Members[0]as Member).Tag = 8;
Members contain exactly what you need (the contries)
RegardsTodor
Thank you for your quick answer, I will test it and let you know.
Hello,
Just a quick follow up to see if Todor's suggestions were helpful and if you had further questions on this matter...
Thanks,