This project is read-only.

How to programmatically set LowerValue, UpperValue, Minimum, Maximum

Oct 30, 2012 at 3:46 PM

Thank you so much for the DateRangeSlider example.

I would appreciate it, if you will instruct me how to programmatically set LowerValue, UpperValue, Minimum, Maximum of DateRangeSlider1 in your source code.

I would like to briefly describe my project, on my Window Form, a grid view display all records from a SQL Table.
Each record contains value of LowerValue, UpperValue, Minimum, Maximum.
When user select a specific record, the LowerValue, UpperValue, Minimum, Maximum will bind to DateRangeSlider1.

Please help !

Thank you so much in advanced.


Nov 1, 2012 at 3:25 AM
Edited Nov 1, 2012 at 3:30 AM

It would just look something like the below.  Each of those are properties on the control and just need to be set to valid DateTime objects.

// Upper and Lower Values
dateRangeSlider1.LowerValue = DateTime.Today;
dateRangeSlider1.UpperValue = DateTime.Now;

// Minimum and Maximum
dateRangeSlider1.Minimum = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
dateRangeSlider1.Maximum = new DateTime(DateTime.Now.Year, DateTime.Now.Month + 1, 1);
However, reading through the rest of your application example, I would recommend using a binding to the selected record in your grid view display, in that case, you would change the XAML, not use code behind.
Nov 1, 2012 at 3:14 PM

Dear Gandora:

Thank you so much for quick response.

Please instruct me how to programmatically set  values of DataRangeSlider1:

// Upper and Lower Values
dateRangeSlider1.LowerValue  to  "10/29/2011 11:22:00 PM"
dateRangeSlider1.UpperValue  to  "10/29/2011 23:59:00 PM"

// Minimum and Maximum
dateRangeSlider1.Minimum to  "10/29/2011 11:10:00 PM"
dateRangeSlider1.Maximum to  "10/29/2011 23:59:00 PM"

Thank you;


Nov 1, 2012 at 3:33 PM


// Upper and Lower Values
dateRangeSlider1.LowerValue = DateTime.Parse("10/29/2011 11:22:00 PM");
dateRangeSlider1.UpperValue = DateTime.Parse("10/29/2011 23:59:00 PM");

// Minimum and Maximum
dateRangeSlider1.Minimum = DateTime.Parse("10/29/2011 11:10:00 PM");
dateRangeSlider1.Maximum = DateTime.Parse("10/29/2011 23:59:00 PM");

Nov 1, 2012 at 6:33 PM

Dear Gandora:

Thank you so much for big help.

Could you please add the 3rd TextBlock that display the TimeSpan(in Second) between LowerValue to UpperValue;

that means:

TimeSpan =  dateRangeSlider1.UpperValue  -  dateRangeSlider1.LowerValue


TimeSpan value automatically updated with UpperValue and LowerValue  


Thank you;