Skip to main content

Microsoft Silverlight

Answered Question How did I manage Scroll BarRSS Feed

(1)

nirav123
nirav123

Member

Member

6 points

5 Posts

How did I manage Scroll Bar

Hello Everyone there

I had developed  a SL2B2 application.I used scrollbar of SL and not the default one.It is working fine But my problem is I am not able to scroll the page through mouse(scrollwheel).Also at one place there is a form to be submitted,which is having enough height,after submit button(at the end of the page) is clicked,forms visibility is set to collapsed and other stackpanel is set to visible which is not having much height,so when button is clicked,I want to goto the top of the page by default how could I do this.

ccoombs
ccoombs

Contributor

Contributor

5122 points

755 Posts

Re: How did I manage Scroll Bar

I don't think mouse wheel scrolling isn't supported yet in beta.  I imagine this is something we'll see in the official release.

 To move to the top of your scrollable area programmatically, you'll want to use:

 nameOfScrollViewer.ScrollToVerticalOffset(0)

amyo
amyo

Contributor

Contributor

3592 points

486 Posts

Re: How did I manage Scroll Bar

I also found mouse wheel scrolling isn't working in beta.

Ccoombs reply is absolutely the answer of this post.

Amyo Kabir
Solution Architect & Sr. Developer
Blog

K2P2
K2P2

Participant

Participant

1026 points

336 Posts

Answered Question

Re: How did I manage Scroll Bar

I found this while working on some Deep Zoom stuff.  It works there.  I haven't time to put together an example so I don't know if it will help you in what you are trying to do.  These event handlers are catching the mouse wheel event though, in a UserControl that I quickly threw together.  (But I dought the logic in the handler is of much use to you.)

if ( HtmlPage.IsEnabled )
{
   HtmlPage.Window .AttachEvent ( "DOMMouseScroll", HandleHtmlMouseWheel );
   HtmlPage.Window .AttachEvent ( "onmousewheel", HandleHtmlMouseWheel );
   HtmlPage.Document .AttachEvent ( "onmousewheel", HandleHtmlMouseWheel );
}

 

private void HandleHtmlMouseWheel ( object sender, HtmlEventArgs args )
{
   double delta = 0;

   ScriptObject eventObj = args.EventObject;

   if ( eventObj.GetProperty( "wheelDelta" ) != null
   {
      delta = ((
double)eventObj.GetProperty( "wheelDelta" ) ) / 120;

      if ( HtmlPage.Window.GetProperty( "opera" ) != null )
         delta = -delta;
   }

   else if ( eventObj.GetProperty( "detail" ) != null
   {
      delta = -((double)eventObj.GetProperty( "detail" ))/3;
      if ( HtmlPage.BrowserInformation.UserAgent.IndexOf( "Macintosh" ) != -1 )
         delta = delta * 3;
   }

 

   if ( delta != 0 ) 
   {
      MouseWheelEventArgs wheelArgs = new MouseWheelEventArgs ( delta );

      if
( wheelArgs.Handled )
         args.PreventDefault();
   }
}

nirav123
nirav123

Member

Member

6 points

5 Posts

Re: Re: How did I manage Scroll Bar

Thanks for help But I had not been able to check it out due lots of other work I am really sorry for that.But as soon as I start my SL project I will chk this and get back to you.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities