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. WPF TabContol problem

WPF TabContol problem

Scheduled Pinned Locked Moved WPF
helpcsharpwpf
5 Posts 3 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.
  • J Offline
    J Offline
    Jacobus01
    wrote on last edited by
    #1

    Hi, I have a wpf window containing a Tabcontol with 2 tab items. Both tab items contain a datagrid and some additional buttons and textboxes. I can't seem to find an event for the tab control that only fires when you select the tab item at the top. SelectionChanged fires for any item that I select in the tab item. I need my datagrid to bind to a new datatable whenever its host tab is selected. Please Help!

    A realJSOPR 2 Replies Last reply
    0
    • J Jacobus01

      Hi, I have a wpf window containing a Tabcontol with 2 tab items. Both tab items contain a datagrid and some additional buttons and textboxes. I can't seem to find an event for the tab control that only fires when you select the tab item at the top. SelectionChanged fires for any item that I select in the tab item. I need my datagrid to bind to a new datatable whenever its host tab is selected. Please Help!

      A Offline
      A Offline
      ABitSmart
      wrote on last edited by
      #2

      A few days ago JSOP mentioned something like this. Look here[^]

      1 Reply Last reply
      0
      • J Jacobus01

        Hi, I have a wpf window containing a Tabcontol with 2 tab items. Both tab items contain a datagrid and some additional buttons and textboxes. I can't seem to find an event for the tab control that only fires when you select the tab item at the top. SelectionChanged fires for any item that I select in the tab item. I need my datagrid to bind to a new datatable whenever its host tab is selected. Please Help!

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

        I created a new TabItem class, like so:

        public class UDPTabItem : TabItem
        {
        	public bool           IsActive { get; set; }
        
        	//--------------------------------------------------------------------------------
        	//--------------------------------------------------------------------------------
        	// Create a custom routed event by first registering a RoutedEventID.  This event 
        	// uses the bubbling routing strategy
        	public static readonly RoutedEvent ActivateEvent = EventManager.RegisterRoutedEvent("Activate", 
                                                   RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UDPTabItem));
        	// Provide CLR accessors for the events
        	public event RoutedEventHandler Activate
        	{
        		add    { AddHandler(ActivateEvent, value);    } 
        		remove { RemoveHandler(ActivateEvent, value); }
        	}
        	// These methods raise the events
        	private void RaiseActivateEvent()
        	{
        		RoutedEventArgs eventArgs = new RoutedEventArgs(UDPTabItem.ActivateEvent);
        		RaiseEvent(eventArgs);
        	}
        
        
        	//--------------------------------------------------------------------------------
        	//--------------------------------------------------------------------------------
        	public static readonly RoutedEvent DeactivateEvent = EventManager.RegisterRoutedEvent("Deactivate", 
                                      RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UDPTabItem));
        	public event RoutedEventHandler Deactivate
        	{
        		add    { AddHandler(DeactivateEvent, value);    } 
        		remove { RemoveHandler(DeactivateEvent, value); }
        	}
        	private void RaiseDeactivateEvent()
        	{
        		RoutedEventArgs eventArgs = new RoutedEventArgs(UDPTabItem.DeactivateEvent);
        		RaiseEvent(eventArgs);
        	}
        
        
        	//--------------------------------------------------------------------------------
        	/// <summary>
        	/// 
        	/// </summary>
        	public UDPTabItem()
        	{
        		this.IsActive = false;
        	}
        
        	//--------------------------------------------------------------------------------
        	/// <summary>
        	/// 
        	/// </summary>
        	/// <param name="activate"></param>
        	public void ActivateTab(bool activate)
        	{
        		IsActive = activate;
        		if (this.IsActive)
        		{
        			RaiseActivateEvent();
        		}
        		else
        		{
        			RaiseDeactivateEvent();
        		}
        	}
        
        	//--------------------------------------------------------------------------------
        	/// <summary>
        	/// 
        	/// </summary>
        	/// <param name="e"></param>
        	protected override void
        
        J 1 Reply Last reply
        0
        • realJSOPR realJSOP

          I created a new TabItem class, like so:

          public class UDPTabItem : TabItem
          {
          	public bool           IsActive { get; set; }
          
          	//--------------------------------------------------------------------------------
          	//--------------------------------------------------------------------------------
          	// Create a custom routed event by first registering a RoutedEventID.  This event 
          	// uses the bubbling routing strategy
          	public static readonly RoutedEvent ActivateEvent = EventManager.RegisterRoutedEvent("Activate", 
                                                     RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UDPTabItem));
          	// Provide CLR accessors for the events
          	public event RoutedEventHandler Activate
          	{
          		add    { AddHandler(ActivateEvent, value);    } 
          		remove { RemoveHandler(ActivateEvent, value); }
          	}
          	// These methods raise the events
          	private void RaiseActivateEvent()
          	{
          		RoutedEventArgs eventArgs = new RoutedEventArgs(UDPTabItem.ActivateEvent);
          		RaiseEvent(eventArgs);
          	}
          
          
          	//--------------------------------------------------------------------------------
          	//--------------------------------------------------------------------------------
          	public static readonly RoutedEvent DeactivateEvent = EventManager.RegisterRoutedEvent("Deactivate", 
                                        RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UDPTabItem));
          	public event RoutedEventHandler Deactivate
          	{
          		add    { AddHandler(DeactivateEvent, value);    } 
          		remove { RemoveHandler(DeactivateEvent, value); }
          	}
          	private void RaiseDeactivateEvent()
          	{
          		RoutedEventArgs eventArgs = new RoutedEventArgs(UDPTabItem.DeactivateEvent);
          		RaiseEvent(eventArgs);
          	}
          
          
          	//--------------------------------------------------------------------------------
          	/// <summary>
          	/// 
          	/// </summary>
          	public UDPTabItem()
          	{
          		this.IsActive = false;
          	}
          
          	//--------------------------------------------------------------------------------
          	/// <summary>
          	/// 
          	/// </summary>
          	/// <param name="activate"></param>
          	public void ActivateTab(bool activate)
          	{
          		IsActive = activate;
          		if (this.IsActive)
          		{
          			RaiseActivateEvent();
          		}
          		else
          		{
          			RaiseDeactivateEvent();
          		}
          	}
          
          	//--------------------------------------------------------------------------------
          	/// <summary>
          	/// 
          	/// </summary>
          	/// <param name="e"></param>
          	protected override void
          
          J Offline
          J Offline
          Jacobus01
          wrote on last edited by
          #4

          Thank you very much. I'm still new to WPF and I'm still getting used to the new event model. So far I'm quite impressed...

          realJSOPR 1 Reply Last reply
          0
          • J Jacobus01

            Thank you very much. I'm still new to WPF and I'm still getting used to the new event model. So far I'm quite impressed...

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

            I've only been doing it since April, and I'm not impressed...

            "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
            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