This is a migrated thread and some comments may be shown as answers.

Double clicking tab makes selectedIndex -1

1 Answer 73 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chris
Top achievements
Rank 1
Chris asked on 16 Jan 2012, 06:20 PM
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,

1 Answer, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 16 Jan 2012, 06:31 PM
Figured it out.

IsMinimizable = False
Tags
RibbonView and RibbonWindow
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Share this question
or