XamScheduleView programmatically set horizontal scrollbar position to a certain Hour to be in View
When the xamScheduleView is populated with appointments the default horizontal scroll position seems to be based on the current time.
I NEED to set the horizontal scroll position to a different hour, for example if I see a time window of 7am - 3pm, I need to programmatically scroll to 6pm...
I have tried setting the active calendar and selected time range, but this has no affect.
Please FW me any documentation that I have missed on how to programmatically set the horizontal scroll position.
Thanks
Hi Jesse,
Thank you for posting in our forums!
We do not have any documentation that addresses setting the horizontal scrollbar programmatically.
I am further investigating how your requirements can be achieved and will update you again tomorrow with my findings.
Sincerely,Michael H.Software DeveloperInfragistics, Inc.www.infragistics.com/support
Hello Jesse,
In order to scroll to a desired time, you will need to get the ScrollBar element from the VisualTree and set it's value.
A little bit of math is required to calculate the scrollbar position, but the following code demonstrates how this is possible.
private void ScrollToTime(XamScheduleView schedule, DateTime dt) { DateTime midnight = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0); TimeSpan scrollTo = dt - midnight; ScrollBar scroller = Infragistics.Windows.Utilities.GetDescendantFromName(schedule, "TimeslotScrollBar") as ScrollBar; // Some math to account for scroll intervals. scroller.Value = scrollTo.TotalMinutes / schedule.TimeslotInterval.TotalMinutes; }
I have also attached a running sample below that demonstrates this.
8371.XamScheduleView_HorizontalScrollToHour.zip
If you have any further questions or concerns with this, please let me know.