We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

PivotItem cannot be selected

Good morning,


I have a problem with a project I am currently working on. I am making a PivotGridControl in wpf .net7. When I try to add a PivotItem I get the error "PivotItem name does not exist in namespace". I will add that I give a reference to xmlns:syncfusion="http://schemas.syncfusion.com/wpf"

Code below:

                <syncfusion:PivotGridControl Name="PivotGrid"

                                             HorizontalAlignment="Left"

                                             Margin="5,0,0,0"

                                             VerticalAlignment="Top"

                                             ItemSource="{Binding Source=ExecutorsPivotGrid}">

                <syncfusion:PivotGridControl.PivotRows>

                                        <syncfusion:PivotItem FieldHeader="Produkt"

                                                              FieldMappingName="ExecutorsPivotGrid.ProductName"

                                                              TotalHeader="Suma"/>

                </syncfusion:PivotGridControl.PivotRows>

                </syncfusion:PivotGridControl>


2 Replies

PI Piotr March 3, 2023 05:52 AM UTC

I managed to solve this problem. I used: 

<pivotbase:PivotItem/>



VS Vijayarasan Sivanandham Syncfusion Team March 3, 2023 07:37 AM UTC

Hi Piotr,

We are glad to know that the reported problem has been resolved at your end. However, the reported problem occurs due to both Syncfusion.PivotAnalysis.Base and Syncfusion.XlsIO dlls are present in a common namespace http://schemas.Syncfusion.com/wpf. Also, PivotItem control is present in both the dlls with the same name, it leads to does not exist in the namespace exception if you reference http://schemas.Syncfusion.com/wpf to your project.

As you mentioned in the previous update, you can resolve the reported problem by explicitly declaring the namespace for PivotItem by specifying the assembly as below,

xmlns:pivotbase="clr-namespace:Syncfusion.PivotAnalysis.Base;assembly=Syncfusion.PivotAnalysis.Base"

Refer to the below code snippet,

<Window x:Class="PivotGridControlDemo.MainWindow"

        xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

        xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

        xmlns:d=http://schemas.microsoft.com/expression/blend/2008

        xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006

        xmlns:local="clr-namespace:PivotGridControlDemo"

        xmlns:syncfusion=http://schemas.syncfusion.com/wpf

        xmlns:pivotbase="clr-namespace:Syncfusion.PivotAnalysis.Base;assembly=Syncfusion.PivotAnalysis.Base"

        mc:Ignorable="d"

        Title="MainWindow" Height="450" Width="800">

    <Window.DataContext>

        <local:ViewModel />

    </Window.DataContext>

   

    <Grid>     

        <syncfusion:PivotGridControl x:Name="pivotGrid1" Margin="5" ItemSource="{Binding ProductSalesData}" >

            <syncfusion:PivotGridControl.PivotRows>

                <pivotbase:PivotItem FieldMappingName="Product" FieldHeader="Product" TotalHeader="Total"/>

                <pivotbase:PivotItem FieldMappingName="Date" FieldHeader="Date" TotalHeader="Total"/>

            </syncfusion:PivotGridControl.PivotRows>

        </syncfusion:PivotGridControl>

    </Grid>

</Window>


Find the sample in the attachment.

UG Link: https://help.syncfusion.com/wpf/pivot-grid/pivotgrid-getting-started

API Link: PivotItem

Regards,
Vijayarasan S

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: PivotGridControlDemo_3eb54ea3.zip

Loader.
Live Chat Icon For mobile
Up arrow icon