Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. TabItem Activation

TabItem Activation

Scheduled Pinned Locked Moved WPF
question
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • realJSOPR Offline
    realJSOPR Offline
    realJSOP
    wrote on last edited by
    #1

    There doesn't appear to be a tab item Activated event of any description. The only thing I've found that fires when a tab item is selected is the Loaded event, which is kinda - well - baffling. Am I missing something?

    "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
    -----
    "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

    P G 2 Replies Last reply
    0
    • realJSOPR realJSOP

      There doesn't appear to be a tab item Activated event of any description. The only thing I've found that fires when a tab item is selected is the Loaded event, which is kinda - well - baffling. Am I missing something?

      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      No you're not, and there is a reason why it behaves this way. It's not a great reason, but it is a reason. Basically, there's only one ContentPresenter showing the contents of the selected tab. This means that the visuals are loaded "on the fly".

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

      My blog | My articles | MoXAML PowerToys | Onyx

      realJSOPR 1 Reply Last reply
      0
      • realJSOPR realJSOP

        There doesn't appear to be a tab item Activated event of any description. The only thing I've found that fires when a tab item is selected is the Loaded event, which is kinda - well - baffling. Am I missing something?

        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        G Offline
        G Offline
        Gideon Engelberth
        wrote on last edited by
        #3

        The TabControl has a SelectionChanged event that seems to fire every time a tab is selected. In that event you can get the new selection as TabControl.SelectedItem.

        realJSOPR 1 Reply Last reply
        0
        • G Gideon Engelberth

          The TabControl has a SelectionChanged event that seems to fire every time a tab is selected. In that event you can get the new selection as TabControl.SelectedItem.

          realJSOPR Offline
          realJSOPR Offline
          realJSOP
          wrote on last edited by
          #4

          I don't need the tab control to know what tab item was selected. I need *the tab item* to know it's been selected. At this point, I'm reacting to the Loaded event (which is a two-bit hack work-around).

          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

          G 1 Reply Last reply
          0
          • P Pete OHanlon

            No you're not, and there is a reason why it behaves this way. It's not a great reason, but it is a reason. Basically, there's only one ContentPresenter showing the contents of the selected tab. This means that the visuals are loaded "on the fly".

            "WPF has many lovers. It's a veritable porn star!" - Josh Smith

            As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

            My blog | My articles | MoXAML PowerToys | Onyx

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            You're right - it's not a good reason. I've now got to monitor whether or not the tab is being created when the Loaded event is fired. It's starting to look like I have create an event myself, just to keep the chaos in the code to a frakking minimum. What a pile of crap...

            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

            1 Reply Last reply
            0
            • realJSOPR realJSOP

              I don't need the tab control to know what tab item was selected. I need *the tab item* to know it's been selected. At this point, I'm reacting to the Loaded event (which is a two-bit hack work-around).

              "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
              -----
              "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

              G Offline
              G Offline
              Gideon Engelberth
              wrote on last edited by
              #6

              Depending on what you are doing when the tab is selected (my psychic assistance is currently offline), I can think of two approaches. The first is to use a style with a trigger on the IsSelected property. The other approach would be to sub-class TabItem and override the OnSelected method.

              J 1 Reply Last reply
              0
              • G Gideon Engelberth

                Depending on what you are doing when the tab is selected (my psychic assistance is currently offline), I can think of two approaches. The first is to use a style with a trigger on the IsSelected property. The other approach would be to sub-class TabItem and override the OnSelected method.

                J Offline
                J Offline
                Jacobus01
                wrote on last edited by
                #7

                I Had the same problem and this was unfortunately the only solution I could think of. private void TendererTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (e.AddedItems[0].GetType().Name == "TabItem") { TabItem SelectedTab = (TabItem)e.AddedItems[0]; if (SelectedTab.Header.ToString() == "Tenderers") { ..... } if (SelectedTab.Header.ToString() == "Contenders") { .... } } } catch (IndexOutOfRangeException) { }

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups