How to Set value for SilverLight Slider?

Class library usage, coding and language questions.
thangavel
Posts: 50
Joined: Tue Jun 09, 2009 6:48 am
Contact:

How to Set value for SilverLight Slider?

Post by thangavel » Fri Mar 25, 2011 12:06 pm

Slider sldrRiskLevel = ilstMainTabPages[0].FindSingle<Slider>("./slider[@automationid='slider']");
double Max = sldrRiskLevel.MaxValue;
double Min = sldrRiskLevel.MinValue;
double Val = sldrRiskLevel.Value;
int intRandVal = new Random().Next((int)Min, (int)Max);
sldrRiskLevel.Value = intRandVal;


From Above code, I'm not getting any error. The value is set successfully. But the slider is not moving. Please help me on this problem. I've attached the snapshot of the slider control.
You do not have the required permissions to view the files attached to this post.
Regards,
Thangavel.S

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: How to Set value for SilverLight Slider?

Post by Support Team » Fri Mar 25, 2011 1:30 pm

Hi,

have you tried to use a double value instead of an integer:
double RandVal = new Random().Next((int)Min, (int)Max);
Regards,
Tobias
Support Team

thangavel
Posts: 50
Joined: Tue Jun 09, 2009 6:48 am
Contact:

Re: How to Set value for SilverLight Slider?

Post by thangavel » Fri Mar 25, 2011 3:41 pm

Thanks for your reply. I found that, this is UI error. After setting the value, The slider is not moving. but it's value is changing behind the code. It is fixed in code behind. Now the code is working. The following two approaches are working fine.

Approach1:
double RandVal = new Random().Next((int)Min, (int)Max);
sldrRiskLevel.Value = intRandVal;

Approach2:
int intRandVal = new Random().Next((int)Min, (int)Max);
sldrRiskLevel.Value = intRandVal;
Regards,
Thangavel.S