Hi,
I try to use the XamPivot to display Data...
I want to know how i can customize the columnHeader to bind more than property ..
A want to display another information with A-136... in this column
the XAML way please.
Thx
Hello Michel,
In order to customize a column or row header in the XamPivotGrid, I would recommend including the default templates for PivotColumnHeaderCellControl and PivotRowHeaderCellControl. These default templates can be found in the generic.shared.xaml file commonly found at the following directory:
C:\Program Files (x86)\Infragistics\<your version here>\WPF\DefaultStyles\XamPivotGrid
Once you have included these default styles and their dependencies, I would recommend that you locate a ContentControl named “HeaderPresenter” in each default template. Here, you can provide a ContentTemplate that can bind to the element you wish to bind to.
I am attaching a sample project that demonstrates this. I am rather unsure what you are looking to bind to in this case, and so the modification of the ContentControl.ContentTemplate in the case of the sample project is bound to the Content of the ContentControl, which is the normal header as well as the addition of some generic text.
Please let me know if you have any other questions or concerns on this matter.
PivotGridFlatDataTest.zip
Thx,
is complex example
if i understand all the job i done in this section :
<ContentControl.ContentTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"><TextBlock Text="{Binding}"/> <TextBlock Text=" SOME CUSTOM COLUMN TEXTTTTT"/> </StackPanel> </DataTemplate> </ContentControl.ContentTemplate>
i wan't to hard code the Text but something like that
<TextBlock Text="{Binding propertyName1}"/>
<TextBlock Text="{Binding propertyName2}"/>
<TextBlock Text="{Binding propertyName3}"/>
How i can acomplish this... an example please.
thx
Thank you for your update on this matter. It is a rather complex example, but that is mainly because the styles for PivotColumnHeaderCellControl and PivotRowHeaderCellControl have quite a few dependencies on other styles. The actual changes are in that ContentControl.ContentTemplate, as it appears you have noticed.
Regarding binding the TextBlock, it really depends on what "propertyName1/2/3" exists on in this case for me to really be able to make a recommendation. For example, does this property exist on the view model in your application that likely contains the data source that you are binding to the XamPivotGrid, or are these properties actually on the underlying data item that in your screenshot above is referenced by the "A-136" column in this case?
Would it be possible for you to please provide some information on the above so I may be able to make a recommendation in this case?
I have to display more info about "A-136" like this
I 'm doing this display by formating all data in the single property like this.
SlaughterPeriodName = $" [{preOrderPeriod.SlaughterPeriodName}] [{effectiveRate}%] {Environment.NewLine} {range.StartPeriod.Value.ToShortDateString()} {range.EndPeriod.Value.ToShortDateString()}";
Thank you for your update on this matter, but I have to admit, I’m slightly confused by your most recent response in this case.
Is your most recent response to say that you have achieved your requirement by formatting all of your data in your “SlaughterPeriodName” property in this case, or do you still need assistance in achieving this behavior?
Thank you very Much !
I have modified the example that I had originally sent you such that the PivotColumnHeaderCell is passed to a converter and a value is returned from that converter. In the converter, it is also demonstrated how you can get back to the XamPivotGrid, it's Olap data source, and the ItemsSource that you provide that source. In your case, you would query the collection returned by this ItemsSource based on the Member property of the PivotColumnHeaderCell that is passed to the converter.
I am attaching the modified example to this post. I hope it helps you.
5141.PivotGridFlatDataTest.zip
Can you put it in the example you sent later
Appreciated.
With the current implementation of the sample project, the styles applied to the PivotColumnHeaderCellControl and PivotRowHeaderCellControl will be applied to any of that element type that exist in the XamPivotGrid. If you are looking to only apply this to certain columns, I would recommend looking at giving these styles an x:Key. Doing this will allow you to retrieve them in code, and then you can apply that given style to the XamPivotGrid.GridLayout.Columns[index].HeaderCellStyle property. This would allow you to essentially define this “ColumnTemplate” that you are looking to achieve. For example, if you were to move the PivotColumnHeaderCellControl style in the sample project I had provided you to the Application.Resources section in your App.xaml and give it an x:Key of “myColumnHeaderStyle”, you could retrieve it and apply it like so, where “pivot” is the XamPivotGrid:
Style style = Application.Resources[“myColumnHeaderStyle”] as Style;pivot.GridLayout.Columns[0].HeaderCellStyle = style;
Once you have done this, you will need a separate way of formatting the string that you wish to show in the header, which of course can be broken up by multiple elements existing in the ContentControl.ContentTemplate as shown in the sample I attached. There does not exist a way to get back to the underlying data item from the PivotColumn/RowHeaderCellControl, though, and so you will very likely have to query your underlying data source in order to get the information needed to format the different pieces of your “column template” in this case.
As an example of how you could do this, you could perhaps use a binding to your PivotColumn/RowHeadeCellControl. This element has a Cell property that will contain either the PivotColumnHeaderCell or the PivotRowHeaderCell that is represented by the cell control. Both of these elements have information about the Member, Row, and Column that they represent, which you may be able to use against your data source to query it and find the data item(s) that are represented by that column or row header. Perhaps to do this, you could use a converter in your binding to the PivotRowHeaderCell or PivotColumnHeaderCell. This binding could look like the following in your ContentControl.ContentTemplate:
<DataTemplate> <TextBlock Text=”{Binding RelativeSource={RelativeSource AncestorType={x:Type ig:PivotColumnHeaderCellControl}}, Path=Cell, Converter={StaticResource converterKey}” /></DataTemplate>
In this case, “converterKey” would be the x:Key of an IValueConverter instance that you bring in as a resource. This converter would look at the PivotRowHeaderCell/PivotColumnHeaderCell, query your underlying data source to your Olap data source being used for the XamPivotGrid, and return a suitable string for your TextBlock.Text property that you place in your header based on the information that your data source returns.
I hope this helps. Please let me know if you have any other questions or concerns on this matter.
I want to do this by configuring a ColumnTemplate to have more control on each property... example
i want to display a [A-136] in bold style and the date in italic style with different color.
so i want to achieve this behavior without the need to format a string.
i want an example to do this behavior.