Hello,
I'm attaching a sample with a XamDataGrid and a button that fills the XamDataGrid with data.
I have an issue with the position of the summary row. I want the summary always to be at the end of the rows and when scrolling down to be 'on top' of the last visible row (like the BottomFixed SummaryDisplayArea property) BUT when the XamDataGrid is empty or the scrollbar is not visible, the summary row should be positioned right after the fields (like the Bottom SummaryDisplayArea property). Is there a way to implement this?
Yes Valerie that worked perfectly. Thank you!
Hello George,
Were you able to resolve your issue?
Sincerely,
Valerie
You can walk the visual tree to get a reference to the scrollbar and then use it visibility to reset the SummaryDisplay Area. For example, you can add the following code to the loaded event of the window:
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
// Get XamDataGrid ScrollBar
DependencyObject dob = (DependencyObject)(this.XamDataGrid);
for (int i = 0; i < 6; i++)
dob = VisualTreeHelper.GetChild(dob, 0);
dob = VisualTreeHelper.GetChild(dob, 2);
if (dob.GetType() == typeof(System.Windows.Controls.Primitives.ScrollBar))
System.Windows.Controls.Primitives.ScrollBar sb = (System.Windows.Controls.Primitives.ScrollBar) dob;
if (!sb.IsVisible)
XamDataGrid.FieldSettings.SummaryDisplayArea = SummaryDisplayAreas.Bottom;
sb.IsVisibleChanged += sb_IsVisibleChanged;
}
And add an event handler for the scrollbar’s visibility changed:
void sb_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
if ((bool) e.NewValue == true)
XamDataGrid.FieldSettings.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
else
Please note, this code assumes you have the initial value set to BottomFixed in your XAML.
To see how the logic for finding the scrollbar was determined you can use a tool like Snoop to view the Visual Tree. To learn more about Snoop, please see http://help.infragistics.com/doc/WPF/2015.2/CLR4.0/?page=WPF_Working_with_xamDataGrid_xamDataCarousel_and_xamDataPresenter_Styling_Points.html.
Let me know if you have any questions.
Software Developer
Infragistics Inc