Scroll Events

2 posts, 0 answers
  1. Chris Evans
    Chris Evans avatar
    19 posts
    Member since:
    Feb 2010

    Posted 25 Aug 2010 Link to this post

    Hello, I am using the latest v.2010.2.812.1040 controls and was wondering if I can attach events to the scroll button clicks of the RadTabControl.  Any help would be appreciated, thank you.
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 30 Aug 2010 Link to this post

    Hi Chris,

    There is no scrolling event exposed, but you can use the VisualTreeHelper class to find the left and right scroll buttons.

    public MainPage()
    {
        InitializeComponent();
     
        // populate the TabControl with some items to force the scroll button to appear
        this.tabControl1.ItemsSource = Enumerable.Range(0, 50);
     
        this.Loaded += new RoutedEventHandler(MainPage_Loaded);
    }
     
    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        this.Dispatcher.BeginInvoke(() =>
        {
            // Get the first element in RadTabControl's visual tree
            var root = VisualTreeHelper.GetChild(this.tabControl1, 0) as Panel;
     
            // Find the LeftScrollButtonElement and RightScrollButtonElement
            RepeatButton leftScrollButtonElement = root.FindName("LeftScrollButtonElement") as RepeatButton;
            Debug.Assert(leftScrollButtonElement != null);
            RepeatButton rightScrollButtonElement = root.FindName("RightScrollButtonElement") as RepeatButton;
            Debug.Assert(rightScrollButtonElement != null);
     
            // Subscribe to their click event
            leftScrollButtonElement.Click += new RoutedEventHandler(LeftScrollButtonElement_Click);
            rightScrollButtonElement.Click += new RoutedEventHandler(RightScrollButtonElement_Click);
        });
    }
     
    private void RightScrollButtonElement_Click(object sender, RoutedEventArgs e)
    {
        MessageBox.Show("RightScrollButton clicked");
    }
     
    private void LeftScrollButtonElement_Click(object sender, RoutedEventArgs e)
    {
        MessageBox.Show("LeftScrollButton clicked");
    }

    Give it a try and let me know if this helps.

    Sincerely yours,
    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