Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Slider Issue - From B1 to B2 RSS

12 replies

Last post Sep 08, 2008 09:02 AM by avinashkr

(0)
  • ercercerc

    ercercerc

    Member

    99 Points

    45 Posts

    Slider Issue - From B1 to B2

    Jun 07, 2008 02:25 PM | LINK

     

     I have an application I am converting from beta 1 to beta 2. I use a slider to provide a zoom control. In beta 1 the following simple code worked fine:

    private void sldZoomLevel_ValueChanged(object sender, RoutedEventArgs e)

       {

          ZoomLevel = (
    int)sldZoomLevel.Value;

       }

    In beta 2 during this method is being called during the app startup sequence, apparently before sldZoomLevel is defined. I get an exception since sldZoomLevel is null. A check for null resolved the issue but I'd like to understand why this happens and if it is limited to sliders.

    Thanks for any help on this.

  • MarauderzMY

    MarauderzMY

    Member

    639 Points

    283 Posts

    Re: Slider Issue - From B1 to B2

    Jun 07, 2008 04:29 PM | LINK

    I  have another issue with the B2 slider so I guess I'll just add on here. The Mouseleftbuttondown event doesn't seem to be firing anymore. I'm using a slider as my video scrubber, which uses a timer to update the value of the slider as the video plays. I suspend the timer when the user holds down the slider thumb so he can move the slider to a new position.

     But of course, it doesn't work anymore right now.

    I'd say the event bubbling changes must be affecting it.

  • Dave Relyea

    Dave Relyea

    Participant

    1090 Points

    252 Posts

    Microsoft

    Re: Re: Slider Issue - From B1 to B2

    Jun 07, 2008 11:40 PM | LINK

    r.e. event bubbling...yes, you won't get the MouseLeftButtonDown because the Slider handles it.

    Dave Relyea [MSFT]
    http://blogs.msdn.com/devdave
  • MarauderzMY

    MarauderzMY

    Member

    639 Points

    283 Posts

    Re: Re: Slider Issue - From B1 to B2

    Jun 09, 2008 06:19 AM | LINK

    Then what am i supposed to do in my situation if i need to know when a user starts dragging the slider. Any solutions other than make my own slider? Or how else do you recommend someone make a video scrubber with the slider now?

  • hwsoderlund

    hwsoderlund

    Member

    429 Points

    123 Posts

    Re: Re: Slider Issue - From B1 to B2

    Jun 10, 2008 01:47 PM | LINK

    I have the exact same problem. I desperately need to handle both the MouseLeftButtonDown and MouseLeftButtonUp events for the Slider. I was hoping that I would be able to inherit from ScrollBar instead, but unfortunately it's sealed. If I had the source code I suppose I could modify the Slider code and compile my own tweaked version. Does anybody know if Microsoft will release the source code for the Beta 2 controls as they did for Beta 1?
  • Aaadi

    Aaadi

    Member

    42 Points

    35 Posts

    Re: Re: Slider Issue - From B1 to B2

    Jun 10, 2008 01:59 PM | LINK

    I had face the same issue and wondering around how to solve it, instead of override slider control code but i think its the last option.

     you can download beta 2 sample code from here

     http://silverlight.net/Samples/2b2/SilverlightControls/run/default.html

     

    Adi
    Software Engineer
    Softech Worldwide LLC
  • tanmoy.r

    tanmoy.r

    Contributor

    4163 Points

    796 Posts

    Microsoft

    Re: Re: Slider Issue - From B1 to B2

    Jun 10, 2008 02:08 PM | LINK

    I am facing same issue with my media player. Another issue about slider style. I want to fill the left part of the slider(slider progress) with a color. There is only one repeatbutton and if I add something it appears on both left and right side.

    Ok I solved the second problem. Silly me :). Just had to use

    HorizontalTrackLargeChangeDecreaseRepeatButton .

     

    Please Mark as Answer if this helps you.
    Thanks n Regards
    ~Tanmoy
    Blog: http://anothersilverlight.blogspot.com/
  • hwsoderlund

    hwsoderlund

    Member

    429 Points

    123 Posts

    Re: Re: Slider Issue - From B1 to B2

    Jun 11, 2008 07:07 AM | LINK

    I sort of have a solution that might solve the video scrubber issue. It involves creating your own derived slider control and adding event handlers for dragstarted and dragcompleted. These events already exist on the Thumb part of the slider, but not on the slider itself. So if we find the Thumb and just pass on the events we can detect when dragging starts and when it ends. Here's the code: 

    using System;

    using System.Windows;

    using System.Windows.Controls;

    using System.Windows.Documents;

    using System.Windows.Ink;

    using System.Windows.Input;

    using System.Windows.Media;

    using System.Windows.Media.Animation;

    using System.Windows.Shapes;

    using System.Windows.Controls.Primitives;

    using System.ComponentModel;

     

    namespace CustomControls

    {

        public class CustomSlider : Slider

        {

            /// <summary>

            /// Thrown when the thumb has been clicked, and dragging is initiated

            /// </summary>

            public event EventHandler<EventArgs> ThumbDragStarted;

     

            /// <summary>

            /// Thrown when the thumb has been released

            /// </summary>

            public event EventHandler<EventArgs> ThumbDragCompleted;

     

            public override void OnApplyTemplate()

            {

                base.OnApplyTemplate();

     

                //Set up drag event handlers

                Thumb thumb = this.GetTemplateChild("HorizontalThumb") as Thumb;

                if (thumb != null)

                {

                    thumb.DragStarted += new DragStartedEventHandler(thumb_DragStarted);

                    thumb.DragCompleted += new DragCompletedEventHandler(thumb_DragCompleted);

                }

            }

     

            void thumb_DragCompleted(object sender, DragCompletedEventArgs e)

            {

                OnThumbDragCompleted(this, new EventArgs());

            }

     

            void thumb_DragStarted(object sender, DragStartedEventArgs e)

            {

                OnThumbDragStarted(this, new EventArgs());

            }

     

            protected virtual void OnThumbDragStarted(object sender, EventArgs e)

            {

                if (ThumbDragStarted != null)

                    ThumbDragStarted(sender, e);

            }

     

            protected virtual void OnThumbDragCompleted(object sender, EventArgs e)

            {

                if (ThumbDragCompleted != null)

                    ThumbDragCompleted(sender, e);

            }

        }

    }

     

  • tanmoy.r

    tanmoy.r

    Contributor

    4163 Points

    796 Posts

    Microsoft

    Re: Re: Re: Slider Issue - From B1 to B2

    Jun 11, 2008 12:33 PM | LINK

    How can I implement click in the slider. Mousebuttonup event? 

    Please Mark as Answer if this helps you.
    Thanks n Regards
    ~Tanmoy
    Blog: http://anothersilverlight.blogspot.com/
  • Aaadi

    Aaadi

    Member

    42 Points

    35 Posts

    Re: Re: Re: Slider Issue - From B1 to B2

    Jun 11, 2008 12:54 PM | LINK

    Hi,

    i have created a customSlider control by inheriting Slider Control, now i want to apply Style/Template to my new CustomSlider control, can you please let me know how to do it?

    Adi
    Software Engineer
    Softech Worldwide LLC