Articles in this section
Category / Section

How to hide the expand and collapse button in WPF PivotGrid?

1 min read

By default, the PivotGrid has been shown with the expander on PivotGrid Rows and Columns. To hide that expander button, you can override the RowHeaderCellStyle and ColumnHeaderCellStyle using the following steps.

Step 1: Define the HeaderCellStyle and override the template which is of target type PivotGridTemplateCell

Step 2: Apply this defined row style to RowHeaderCellStyle and ColumnHeaderCellStyle property using Style property.

Step 3: Now the PivotGrid has been shown with Text alone without expander button.

XAML:

 
  <Window.Resources>
        <Style x:Key="HeaderCellstyle" TargetType="sync:PivotGridTemplateCell">
            <Setter Property="MinHeight" Value="25" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="sync:PivotGridTemplateCell">
                        <StackPanel Grid.Column="1" Orientation="Horizontal">
                          <!--Template with TextBlock alone-->
                            <TextBlock
                                Grid.Column="1"
                                Margin="3,4,2,0"
                                VerticalAlignment="Top"
                                FontFamily="Segoe UI"
                                FontSize="12"
                                Text="{Binding Path=Text, RelativeSource={RelativeSource TemplatedParent}}"
                                TextWrapping="Wrap" />
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
 
    <Grid>
        <sync:PivotGridControl x:Name="PivotGridControl1">
            <sync:PivotGridControl.RowHeaderCellStyle>
                <sync:PivotGridCellStyle Style="{StaticResource HeaderCellstyle}" />
            </sync:PivotGridControl.RowHeaderCellStyle>
            <sync:PivotGridControl.ColumnHeaderCellStyle>
                <sync:PivotGridCellStyle Style="{StaticResource HeaderCellstyle}" />
            </sync:PivotGridControl.ColumnHeaderCellStyle>
        </sync:PivotGridControl>
 
  </Grid>

Screenshot shows the PivotGrid has expand button

screenshot shows expand button with row and columns of PivotGrid

 

Screenshot shows the PivotGrid appeared without expand button

 


PivotGrid without Expand button

 

 View Sample in GitHub


Conclusion

I hope you enjoyed learning about how to hide the expand and collapse button in WPF PivotGrid.

 You can refer to our WPF PivotGrid feature tour  page to know about its other groundbreaking feature representations. You can also explore  documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied