Is it possible to access the horizontal offset, which I can\'t find in the property list of the datagrid ?
Thanks
Just name the base control (e.g. ListView) in XAML and access it by name in the code behind.
In XAML
<DataGrid Name="dataGrid1" ..... />
If you want to access to the HorizontalOffset you need to access to the ScrollViewer contained inside the Datagrid
one possible method to access the ScrollViewer is
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(dataGrid1); i++)
{
if (VisualTreeHelper.GetChild(dataGrid1, i) is ScrollViewer)
{
ScrollViewer scroll =
(ScrollViewer)(VisualTreeHelper.GetChild(dataGrid1, i));
Console.WriteLine(scroll.HorizontalOffset);
}
}
Note that scroll.HorizontalOffset
is read-only