データグリッドの列ピン固定APIは、列の Pinned プロパティ、つまり PinnedPositions を設定するか、グリッドの PinColumn 関数を設定することで有効にできます。
Pinned プロパティに 3 つのオプションがあります。
-
Left - Left を有効にすると、ピン固定した列がグリッドの左側に配置されます。
-
Right - Right を有効にすると、ピン固定した列がグリッドの右側に配置されます。
-
None - None を有効にすると、列のピン固定を解除し、グリッド内のデフォルトの配置を再配置します。
ピン固定された列に近接するピン固定されていない列は、水平スクロールを維持します。
PinColumn 関数に 2 つのパラメーターがあります。最初のパラメーターはピン固定する列で、2 番目は PinnedPositions 列挙体設定です。
xmlns:ig="clr-namespace:Infragistics.XamarinForms.Controls.Grids;assembly=Infragistics.XF.DataGrid"
...
<ig:XamDataGrid ItemsSource="{Binding}">
<ig:TextColumn HeaderText="DataName" PropertyPath="Name" HorizontalAlignment="Center" Pinned="Left" />
</ig:XamDataGrid>
ContactsDataSource data = new ContactsDataSource();
XamDataGrid grid = new XamDataGrid() { ItemsSource = data };
//Pin via PinColumn function
this.grid.PinColumn(this.grid.Columns[0], PinnedPositions.Left);
//Pin via Pinned property
this.DataGrid.Columns[0].Pinned = PinnedPositions.Left;
以上のコード スニペットは以下のような XamDataGrid になります。