void slider_MouseEnter(object sender, MouseEventArgs e)
        {
            Point p = e.GetPosition(
#if SILVERLIGHT
                Application.Current.RootVisual
#else
                Application.Current.MainWindow
#endif
                );

            sliderTooltipHorizontalOffset = p.X;
            showSliderTooltip(p);
            Slider slider = sender as Slider;

            if (slider != null && sliderTooltipControl != null)
            {
                sliderTooltipControl.SetTooltipText(slider.Value.ToString("N2"));
            }
        }
        public Slider AddSlider(Color rectangleColor)
        {
            Slider slider = new Slider()
            {
                Tag = _sliders.Count,
                Minimum = this.Minimum,
                Maximum = this.Maximum,
                Orientation = this.Orientation,                
                Cursor = Orientation == Orientation.Vertical ? Cursors.SizeNS : Cursors.SizeWE
            };
            Style sliderStyle = Application.Current.Resources["SliderStyle"] as Style;
            if (sliderStyle != null)
                slider.Style = sliderStyle;
            if (Orientation == Orientation.Vertical)
            {
                slider.Height = this.Height;
                slider.Width = 22;
            }
            else
            {
                if (_sliders.Count > 0)
                    slider.Width = _sliders[0].Width;
                //else if (_maxLabel != null)
                //    slider.Width = this.Width - _maxLabel.ActualWidth;
                else
                    slider.Width = this.Width;
                slider.Height = 26;
            }

            if (_sliders.Count == 0)
                slider.Value = (this.Minimum + this.Maximum) / 2;
            else
                slider.Value = (_sliders[_sliders.Count - 1].Value + this.Maximum) / 2;

            slider.MouseEnter += new MouseEventHandler(slider_MouseEnter);
            slider.MouseLeave += new MouseEventHandler(slider_MouseLeave);
            slider.MouseMove += new MouseEventHandler(slider_MouseMove);
            if (sliderTooltip == null)
            {
                sliderTooltip = new Popup();
                sliderTooltipControl = new SliderTooltipControl();
                sliderTooltip.Child = sliderTooltipControl;
                sliderTooltipControl.SetTooltipText(slider.Value.ToString("N2"));
            }

            _sliders.Add(slider);

            if(CanvasRoot != null)
                CanvasRoot.Children.Add(slider);

            addRectangle(rectangleColor);

            slider.ValueChanged += Slider_ValueChanged;
            return slider;
        }
        public Slider AddSlider(Color rectangleColor)
        {
            Slider slider = new Slider()
            {
                Tag         = _sliders.Count,
                Minimum     = this.Minimum,
                Maximum     = this.Maximum,
                Orientation = this.Orientation,
                Cursor      = Orientation == Orientation.Vertical ? Cursors.SizeNS : Cursors.SizeWE
            };
            Style sliderStyle = Application.Current.Resources["SliderStyle"] as Style;

            if (sliderStyle != null)
            {
                slider.Style = sliderStyle;
            }
            if (Orientation == Orientation.Vertical)
            {
                slider.Height = this.Height;
                slider.Width  = 22;
            }
            else
            {
                if (_sliders.Count > 0)
                {
                    slider.Width = _sliders[0].Width;
                }
                //else if (_maxLabel != null)
                //    slider.Width = this.Width - _maxLabel.ActualWidth;
                else
                {
                    slider.Width = this.Width;
                }
                slider.Height = 26;
            }

            if (_sliders.Count == 0)
            {
                slider.Value = (this.Minimum + this.Maximum) / 2;
            }
            else
            {
                slider.Value = (_sliders[_sliders.Count - 1].Value + this.Maximum) / 2;
            }

            slider.MouseEnter += new MouseEventHandler(slider_MouseEnter);
            slider.MouseLeave += new MouseEventHandler(slider_MouseLeave);
            slider.MouseMove  += new MouseEventHandler(slider_MouseMove);
            if (sliderTooltip == null)
            {
                sliderTooltip        = new Popup();
                sliderTooltipControl = new SliderTooltipControl();
                sliderTooltip.Child  = sliderTooltipControl;
                sliderTooltipControl.SetTooltipText(slider.Value.ToString("N2"));
            }

            _sliders.Add(slider);

            if (CanvasRoot != null)
            {
                CanvasRoot.Children.Add(slider);
            }

            addRectangle(rectangleColor);

            slider.ValueChanged += Slider_ValueChanged;
            return(slider);
        }