How to Set value for SilverLight Slider? : Automation API

How to Set value for SilverLight Slider?

Class library usage, coding and language questions.

How to Set value for SilverLight Slider?

Postby thangavel » Fri Mar 25, 2011 1: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.
Attachments
RiskLevel_Slider.rxsnp
(7.83 KiB) Downloaded 22 times
Regards,
Thangavel.S
thangavel
 
Posts: 44
Joined: Tue Jun 09, 2009 7:48 am

Re: How to Set value for SilverLight Slider?

Postby Support Team » Fri Mar 25, 2011 2: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
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: How to Set value for SilverLight Slider?

Postby thangavel » Fri Mar 25, 2011 4: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
thangavel
 
Posts: 44
Joined: Tue Jun 09, 2009 7:48 am


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests