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

Tab Control event won't show grid

3 Answers 76 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Rich Gouette
Top achievements
Rank 1
Rich Gouette asked on 05 Nov 2009, 07:36 PM

I have a RadTabControl, with 4 tabs.

Under each tab, I have a grid.

I want to set the grids to collapsed as default.

Then, upon "MouseLeftButtonDown" Event, I wish to SHOW the respective grid.

When I'm running the app, the grids hide, but MouseLeftButtonDown on the tab doesn;t do anything...

 

I did try another buttons click event, and it does make the grid in question show.

Thoughts?

Rich

3 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 06 Nov 2009, 09:57 AM
Hello Rich,

RadTabItem handles its MouseLeftButtonDown event. That is why, you will have to attach a handler that receives MouseLeftButtonDown events even if they are handled.

tabItem.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(Item_MouseLeftButtonDown), true);

I have attached a sample project demonstrating this scenario. Give it a try and let me know how it works for you.

Best wishes,
Kiril Stanoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Rich Gouette
Top achievements
Rank 1
answered on 06 Nov 2009, 03:04 PM

Howdy Kiril, and thanks for the reply.
Maybe it's b/c I'm a bit of a noob, but I'm getting a failure on line #13 

tabItem.[AddHandler](FrameworkElement.MouseLeftButtonDownEvent, New MouseButtonEventHandler(Item_MouseLeftButtonDown), True)


My code(vb) is:

Public Sub New()

InitializeComponent()

For Each tabItem As RadTabItem In tabControl1.Items

tabItem.[AddHandler](FrameworkElement.MouseLeftButtonDownEvent, New MouseButtonEventHandler(Item_MouseLeftButtonDown), True)

Next

 

 

 

End Sub

 

 

 

Private Sub Item_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)

Me.VisualizeContent()

End Sub

 

 

 

Private Sub tabControl1_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)

Me.VisualizeContent()

End Sub

 

 

 

Private Sub VisualizeContent()

Dim tabItem As RadTabItem = TryCast(tabControl1.SelectedItem, RadTabItem)

TryCast(tabItem.Content, FrameworkElement).Visibility = Visibility.Visible

End Sub


Failure is:
Error 1 Delegate 'System.Windows.Input.MouseButtonEventHandler' requires an 'AddressOf' expression or lambda expression as the only argument to its constructor. D:\VisualStudioProjects\AEMR RequestForm\AEMRrequestForm\AEMRrequestForm\MainPage.xaml.vb 13 105 AEMRrequestForm

 

0
Kiril Stanoev
Telerik team
answered on 12 Nov 2009, 01:08 PM
Hi Rich,

The line that says:

tabItem.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(Item_MouseLeftButtonDown), true);
 has to become:

tabItem.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, New MouseButtonEventHandler(AddressOf Me.Item_MouseLeftButtonDown), True)

I am attaching a converted version of the previous example. Let me know if this is of any help.

All the best,
Kiril Stanoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TabControl
Asked by
Rich Gouette
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Rich Gouette
Top achievements
Rank 1
Share this question
or