My MouseLeftButtonDown does not work at all?

2 posts, 0 answers
  1. Zinc Deng
    Zinc Deng avatar
    13 posts
    Member since:
    Dec 2009

    Posted 23 Mar 2010 Link to this post

    I updated the control to  2010 Q1 and also met this problem
    My MouseLeftButtonDown does not work at all!

    xaml code is as following:
    <UserControl x:Class="CoachStation.test_Slider"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
        Width="400" Height="300">
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadSlider SmallChange="1" x:Name="sdr_timeLine" Grid.Column="0" Grid.Row="0"  Width="710" MouseLeftButtonDown="sdr_timeLine_MouseLeftButtonDown"  MouseLeftButtonUp="sdr_timeLine_MouseLeftButtonUp"></telerik:RadSlider>
        </Grid>
    </UserControl>

    cs code is as following:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    namespace CoachStation
    {
        public partial class test_Slider : UserControl
        {
            public test_Slider()
            {
                InitializeComponent();
            }

            private void sdr_timeLine_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                MessageBox.Show("down");
            }

            private void sdr_timeLine_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            {
                MessageBox.Show("up");
            }
        }
    }

  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 24 Mar 2010 Link to this post

    Hi Zinc Deng,

    Thank you for your feedback. This is expected behavior, since general guidelines state that if a certain control is doing something after a user-triggered action, the the event should be handled. If you still want to use the MouseLeftButtonDown event, you can add a handler as shown bellow:

    public MainPage()
    {
        InitializeComponent();
        sdr_timeLine.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(sdr_timeLine_MouseLeftButtonDown), true);
    }
     
    private void sdr_timeLine_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        if (e.OriginalSource is Rectangle)
        {
            MessageBox.Show("down");
        }
    }

    Let us know how this works for you.

    Regards,
    Kiril Stanoev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
Back to Top