Hi,
I have a XamPivotGrid that gets its data from an xml that is filtered according to a start and end date the user chooses.
So every time a user changes the start and end date i call the function that filters my xml and then change the pivot grid's ItemsSource like below:
ObservableCollection<MarketShares> mSharesData = SampleDataGenerator.GenerateMarketShares((DateTime)this.datepicker1.Tag, (DateTime)this.datepicker2.Tag);
((FlatDataSource)this.pivotGrid.DataSource).ItemsSource = mSharesData;
this will affect the view of the grid. Meaning that the grid will collapse and i will see the Total View only unless the user clicks to expand. I tried calling the ResultsChanged function to expand the view like below:
this.pivotGrid.DataSource.ResultChanged += DataSource_ResultChanged;
it worked, but the grid is being refreshed in a very obvious way where you could capture for a second the Total View being expanded. Is there a way to have the grid expanded in a less obvious way?
Thanks,
nazha
Hi
You can read this post. May be it will work for you.
Todor
I checked the post and tried what they suggested, it didn't work. As i have mentioned before, this issue occurs after changing the ItemsSource of the pivotgrid when the user changes a certain time period. So you would see the grid Collapsing to Total Value and then expanding to see all the items.
i want to find a smoother way for this change because it is obvious for the viewer that the grid is collapsing and then expanding.
Nazha
Hello Nazha,
My advice is to create a CollectionViewSource over all of the data you have in the xml and then pass CollectionViewSource.View as items source. Then you can apply a filter to it:
Call this part when the user has changed the filter parameters:
if (collectionViewSource.View.CanFilter)
{
collectionViewSource.View.Filter =
new Predicate<MarketShares>(this.ApplyFilter);
}
In ApplyFilter method you have to set your rules about to determine if the item is appropriate for inclusion in the view.
public bool ApplyFilter(MarketShares instance)
if (instance.StartDate >= this.StartDate &&
instance.EndDate <= this.EndDate)
return true;
return false;
Regards.
Plamen.
Hello Plamen,
I am passing in an xml containing some values from a web service and I want to display these values for a filter dimension's values instead of those displayed by the xampivotgrid. I read the above post and could not quite follow it.
Can you tell me how I can do that?With an example?My xml elements are read as a collection of strings in the UI code.And I want to display these strings to the user to choose from for the filtering.
Thanks