Tab Control event won't show grid

4 posts, 0 answers
  1. Rich Gouette
    Rich Gouette avatar
    12 posts
    Member since:
    Nov 2009

    Posted 05 Nov 2009 Link to this post

    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

  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 06 Nov 2009 Link to this post

    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.
  3. DevCraft banner
  4. Rich Gouette
    Rich Gouette avatar
    12 posts
    Member since:
    Nov 2009

    Posted 06 Nov 2009 Link to this post

    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

     

  5. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 12 Nov 2009 Link to this post

    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.
Back to Top