This is a migrated thread and some comments may be shown as answers.

Scroll Events

1 Answer 46 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Chris Evans
Top achievements
Rank 1
Chris Evans asked on 25 Aug 2010, 04:27 PM
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.

1 Answer, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 30 Aug 2010, 12:36 PM
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
Tags
TabControl
Asked by
Chris Evans
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Share this question
or