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
  1. Home
  2. General Programming
  3. WPF
  4. Canceling tab selection

Canceling tab selection

Scheduled Pinned Locked Moved WPF
csharpquestionwpfwinforms
1 Posts 1 Posters 1 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.
  • Y Offline
    Y Offline
    yanairon
    wrote on last edited by
    #1

    Hi, does anybody knows what is the WPF way to avoid Tab Selection? in WinForms i had the Selecting event which i could cancel (with CancelEventArgs) i need to cancel (or not) based on the tab which i"m exiting (the previous tab). i get all that information in SelectionChanged but that's too late to cancel. i can't use MouseClick because i don't have all the information i need. all i've managed is the following (ugly) code in SelectionChanged:

        if (!m\_InSelectionChanged && e.Source == e.OriginalSource)
            {
                m\_InSelectionChanged = true;
                if (e.RemovedItems.Count > 0)
                {
                    TabItem unselecetd = e.RemovedItems\[0\] as TabItem;
                    TabItem selected = e.AddedItems\[0\] as TabItem;
    
                    if (selected != null && unselecetd != null)
                    {
                        CancelEventArgs args = new CancelEventArgs();
                        Check(args);
                        if (!args.Cancel)
                        {
                             // Logic    
                        }
                        else
                        {
                            // Re select what was previously selected
                            m\_TabControl.SelectedItem = unselecetd;
                        }
                    }
                }
                m\_InSelectionChanged = false;
            }
    

    any other ideas? no way that it can't be done in wpf with some technique yanai

    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