Hi Guys,
Is it possible to drag out measures, columns and rows like the Xamdatagrid, with 'X" sign coming up. How do we make that to work here in the PivotGrid?
Cheers,
anand
Hello Anand,
This should be occurring by default when you drag out the measures, columns and rows. Please see my attached sample. When I add a measure or dimension and then try to remove it by dragging it out, the cursor is replaced with an X. Do you not see this?
Hey Rob,
It works like a charm!!! Duhh, Sorry I mistakenly overrode that. Sorry about that. Also is there any way we can change the look 'X' of the drag adorner?
Anand
What blackish theme do you mean? Is it one of the themes we provide?
Couldn't you just set the Background property in the FilterFieldItemControl style to change it's color? Unless you are referring to a different part of the control.
I don't quite understand what you mean by how you can make the FieldItemTemplate use your converted value. What converted value specifically? The result of your "PivotConv" converter? You seem to be using it in your example DataTemplate for the TextBlock.Text. Are you trying to use it elsewhere?
No this is a custom dark theme.
I meant, change the background color of the drag adorner of when its dragged from FilterFieldItemControl. I know how to style the FilterFieldItemControl fine.
Even though I change the color of the filterfielditemcontrol, the drag adorner stays the same light blue/green color.
This is following where the FieldItemTemplate is used as ItemTemplate in ColumnsFieldDropAreaControl for example
<ssp:ColumnsFieldDropAreaControl Drop="ColumnsDropControl_Drop" AllowDrop="True" DockPanel.Dock="Right" Margin="2,0,0,0" FontWeight="Normal" x:Name="ColumnsDropArea" Grid.Column="0" Grid.Row="1" ItemTemplate="{StaticResource FieldItemTemplateKey1}" ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataSource.Columns, Mode=TwoWay}" IsEnabled="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataSource.Columns.IsEditable}" />
Ah ok. I gotcha. I will take a look and get back to you.
It turns out that there is a separate template being used for dragging that you are seeing. It doesn't actually use the FilterFieldItemControl as the template for the drag. Unfortunately this template is also an internal template that is not exposed to developers. I tried to see if there was some way to override it using a similar approach as to what I used before with the 'X' icon but there were no good events for this. I had wanted to stay away from this other option as long as possible but based on the way we developed this I don't see another way.
The option I'm talking about is to use reflection to change the internal drag templates. Inside the pivot grid there is an internal class called PivotGridDataTemplates. Using reflection we can get the Type object for this class and then get it's fields. We need to get the fields and not the properties because the properties do not have any setters. And based on how the properties are setup, setting the fields directly would be better. Here is an example of one of the properties.
public static DataTemplate DragTemplate { get { if (_resources == null) { _resources = GetResources(); } if (_dragTemplate == null) { _dragTemplate = _resources["dragTemplate"] as DataTemplate; } return _dragTemplate; } }
As you can see, if _dragTemplate is not null then it won't get the DataTemplate from the resource dictionary. So if we set it before it tries to get the template then it will use our template instead of the default one from now on. Here is the code:
Assembly test = Assembly.GetAssembly(typeof(XamPivotGrid)); Type type = test.GetType("Infragistics.Controls.Grids.PivotGridDataTemplates"); FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Static); fields.ElementAt(1).SetValue(null, LayoutRoot.Resources["dragTemplate"] as DataTemplate);
"fields.ElementAt(1)" will give you the above _dragTemplate field and then set it to my own DataTemplate. You can do this when the window's Loaded event has fired. You can also use this approach for the 'X' icon instead of the way we did it before. For the remove icon, it will be fields.ElementAt(2).
Thanks for your research in this..