Double clicking tab makes selectedIndex -1

2 posts, 0 answers
  1. Chris
    Chris avatar
    3 posts
    Member since:
    Oct 2011

    Posted 16 Jan 2012 Link to this post

    I am having an issue with a RadRibbonTab where if a tab is double clicked, in my selection changed event handler, the (sender as RadRibbonView).SelectedIndex = -1.  This causes a huge blank white rectangle to appear where my button content should go.

    I tried fixing this in code, but it seems for some reason that when the SelectionChanged event returns, it is called again, resulting in an infinite loop.  Here is the method I am using.

    private void ribbonView_SelectionChanged(object sender, RadSelectionChangedEventArgs e)
    {          
       RadRibbonTab selectedTab = e.AddedItems.Count > 0 ? e.AddedItems[0] as RadRibbonTab : e.RemovedItems[0] as RadRibbonTab;
                            
       if (ribbonView.SelectedIndex < 0) ribbonView.SelectedItem = selectedTab;
     
       if (selectedTab != null)
       {
          // no code
       }
    }

    Here is what's going on for a double clicked tab (double clicking tab that is already active):  

    First Click:
        Nothing happens (tab already active)
     
    Second Click:
        Enter SelectionChanged, e.AddedItems.Count = 0, e.RemovedItems.Count = 1
        SelectedIndex == -1, ribbonView.SelectedItem = selectedTab (not null)
            Enter new SelectionChanged, e.AddedItems.Count = 1, e.RemovedItems.Count = 0
            skip assignment to ribbonView.SelectedItem (SelectedIndex == 0)
            return
        return
        Instantly back into SelectionChanged handler again, with  e.AddedItems.Count = 0, e.RemovedItems.Count = 1
          SelectedIndex == -1, ribbonView.SelectedItem = selectedTab (not null)
               Enter SelectionChanged again...
     
    Result:
        The call stack oscillates forever between 2 active calls and 1 active call to the selectionChanged handler. 

    Is there any way around this, or should I do something different in my code?  I tried using if (e.AddedItems.Count < 1) instead of if (ribbonView.SelectedIndex < 0), this results in the same issue.

    What can I do to make my ribbonView buttons not disappear into a huge white rectangle on double click?

    Thanks,
  2. Chris
    Chris avatar
    3 posts
    Member since:
    Oct 2011

    Posted 16 Jan 2012 Link to this post

    Figured it out.

    IsMinimizable = False
  3. DevCraft banner
Back to Top