Skip to main content

Microsoft Silverlight

Answered Question Auto window scrolling....RSS Feed

(0)

CarlBruiners
CarlBrui...

Member

Member

32 points

30 Posts

Auto window scrolling....

 Hi All,

 I have a Silverlight canvas which has draggable objects on it, as the canvas width is greater than the horz. res I have horz. scroll bars.

I have a peice of JS that is updated with the location of a card and if it is being dragged then the window will auto scroll accordingly, the problem is that when I drag an object to the right, the scroll rate is way to quick and jagged, but when I drag a object left the scroll rate is very slow.

Here is the JS;

function getSilverlightMouse(xCoor) {
window.scrollTo(xCoor, 0);
}

I use the following code in the XAML code behind to call the JS (this code sits in my object_MouseMove method);

            If point.X > 15 Then
HtmlPage.Window.CreateInstance("getSilverlightMouse", point.X - 15)
Else
HtmlPage.Window.CreateInstance("getSilverlightMouse", 0)
End If

 Does anyone know how to improve the above code so that scrolling either to the left or right will be done at the same rate? Or how to make things more smooth?

I've seen a scrollby JS method, but I'm not sure this offers me any benefits.

Cheers

Carl
[::TILL THE END::]

SharpGIS
SharpGIS

Contributor

Contributor

3387 points

611 Posts

Answered Question

Re: Auto window scrolling....

The speed difference makes sense, considering you are changing the coordinates underneath the mouse. Either you should take that into account, or you should handle the scrolling inside Silverlight instead of the JavaScript level. In Silverlight it's pretty easy to convert relative coordinates between elements using TransformToVisual.

--
/Morten | blog - twitter
Please click on "Mark as Answer" if this answered your question.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities