Category / Section
How to scale the pivot grid columns and rows to the size of the window
1 min read
We would like to inform you that PivotGrid Control also has ColumnSizer attribute to make grid columns to resize themselves automatically to fit the column content using this.pivotGrid1.InternalGrid.Model.Options.ColumnSizer = GridControlLengthUnitType.Star; in pivotGrid loaded event.
C#
using System.Windows; using Syncfusion.Windows.Controls.Grid; namespace PivotUpdating { public partial class MainWindow : Window { #region Constructor public MainWindow() { InitializeComponent(); this.pivotGrid1.Loaded += new RoutedEventHandler(pivotGrid1_Loaded); } void pivotGrid1_Loaded(object sender, RoutedEventArgs e) { this.pivotGrid1.InternalGrid.Model.Options.ColumnSizer = GridControlLengthUnitType.Star; } #endregion } }
We would like to inform you that you can use “HorizontalAlignment” as Stretch to get the size of columns according to the width of the host panel.
XAML
<syncfusion:PivotGridControl x:Name="pivotGrid1" Grid.Column="0" Grid.Row="2" EnableValueEditing="True" IsDynamicData="True" AllowSelection="False" HorizontalAlignment="Stretch" ItemSource="{Binding ProductSalesData}" AutoSizeOption="TotalRows" EnableUpdating="True" StatePersistenceEnabled="True">