Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > RibbonBar > Collapsing RadRibbonTab minimized popup

Not answered Collapsing RadRibbonTab minimized popup

Feed from this thread
  • Christopher avatar

    Posted on Sep 1, 2011 (permalink)

    Hello,

    I've been having some trouble getting the minimized popup for a RadRibbonTab to stay closed when it is added to a RadRibbonBar at runtime.

    The tab in question is part of a RadRibbonContextualGroupContainer, "GridToolbarControl," which is added to the RadRibbonBar at runtime like so:

    ToolBar.ContextualGroupContainer = new GridToolbarControl();
    ToolBar.PopupOpened += new RoutedEventHandler(ToolBar_PopupOpened);

    I've tried using this event handler to close the tab when it opens:

    void ToolBar_PopupOpened(object sender, RoutedEventArgs e)
    {
        if (sender is RadRibbonBar)
        {
            RadRibbonBar bar = sender as RadRibbonBar;
     
            Popup popup = bar.FindChildByType<Popup>();
     
            if (popup != null && popup.IsOpen)
            {
                popup.IsOpen = false;                   
            }
        }
    }

    However, when this handler is called, "popup.IsOpen" in the condition evaluates to false, then the tab opens anyway. The IsSelected property on the tab is set to false in the XAML, so hopefully it is not trying to select the tab when it is added to the ribbon.

    At this point I am at a loss for how to give the user access to the new contextual group (i.e. IsActive = true), but also ensure the ribbon stays completely minimized until the user clicks on a tab. Is there any way for me to do this?

    Thanks,
    Chris

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Sep 2, 2011 (permalink)

    Hello Christopher ,

    Can you try handling the RadRibbonBar.PreviewPopupOpened event instead:
    private void radRibbonView_PreviewPopupOpened(object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
        e.Handled = true;
    }
    You may only need to implement a logic to control if the MinimizedContent is opened by the user or by adding the contextual groups.

    Regards,
    Tina Stancheva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

    Reply

  • Christopher avatar

    Posted on Sep 2, 2011 (permalink)

    Hello Tina,

    Thank you for your help! I've tried out the event handler you suggested and it works quite well. After trying out various combinations of click and mouse-over events, I settled on detecting user action with a simple MouseEnter event:

    bool toolbarPopupLocked;
     
    private void setupToolbar()
            {
                // If current contextual toolbar is not a grid toolbar, attach a grid toolbar to the current contextual toolbar group.
                if (toolbar == null)
                {
                    toolbarPopupLocked = true;
                    globals.ToolBar.ContextualGroupContainer = new GridToolbarControl();
     
                    globals.ToolBar.PreviewPopupOpened += new Telerik.Windows.RadRoutedEventHandler(ToolBar_PreviewPopupOpened);
                    globals.ToolBar.MouseEnter += new System.Windows.Input.MouseEventHandler(ToolBar_MouseEnter);
                }
            }
     
            void ToolBar_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
            {
                globals.ToolBar.MouseEnter -= new System.Windows.Input.MouseEventHandler(ToolBar_MouseEnter);
                toolbarPopupLocked = false;
            }       
     
            void ToolBar_PreviewPopupOpened(object sender, Telerik.Windows.RadRoutedEventArgs e)
            {
                if (toolbarPopupLocked)
                {
                    e.Handled = true;
                }
                else
                {
                    globals.ToolBar.PreviewPopupOpened -= new Telerik.Windows.RadRoutedEventHandler(ToolBar_PreviewPopupOpened);
                }
            }

    However, one relatively minor problem now: once the "e.Handled = true;" line is executed, the popup will not open until the user clicks on one of the main tabs (non-contextual) of the toolbar.

    Basically what happens is this:
    1. The contextual group is added, the PreviewPopupOpened event fires, and it is prevented from opening by e.Handled = true. (Thank you!)
    2. The user mouses over the toolbar, and the MouseEnter event fires as expected, setting the "locked" variable to false. This happens whether the user mouses over a main tab or the contextual tab.
    3. If the user then clicks on a main tab, the PreviewPopupOpened event fires, locked is evaluated to false, and the popup opens as expected. However, if the user clicks on the contextual tab instead, the PreviewPopupOpened event never fires, and the popup does not open.
    4. If the user clicks on a main tab and then the contextual tab, the contextual tab does open.

    Is there anything I can do about this? It's almost as though the left click event for the contextual menu is being disabled when the popup is prevented from opening, then re-enabled when you click on another tab of the toolbar. The XAML for the toolbar itself is as follows, in case it is needed:

    <telerik:RadRibbonBar x:Name="ToolBarControl"
                                  telerik:Theming.Theme="Expression_Dark"
                                  VerticalAlignment="Top"
                                  ApplicationButtonVisibility="Visible"
                                  MinimizeButtonVisibility="Collapsed"
                                  TitleBarVisibility="Collapsed"
                                  QuickAccessToolBarPosition="NotHosted"
                                  HorizontalAlignment="Stretch"
                                  HorizontalContentAlignment="Left"
                                  IsTabStop="True"
                                  IsApplicationMenuOpen="True"
                                  IsMinimized="True"
                                  ApplicationName="Data Designer"
                                  Grid.RowSpan="2"
                                  ApplicationButtonType="Office2010">
                <telerik:RadRibbonBar.ApplicationButtonContent>
                    <TextBlock Text="A/R"
                               VerticalAlignment="Center"
                               Foreground="White"
                               HorizontalAlignment="Center"
                               Margin="0 4 0 0" />
                </telerik:RadRibbonBar.ApplicationButtonContent>
                <telerik:RadRibbonBar.Backstage>
                    <local_toolbar:ToolBoxBackstage x:Name="BackStage" />
                </telerik:RadRibbonBar.Backstage>
                <local:ToolBarMainTab Header="Main"
                                      Height="Auto"
                                      x:Name="MainTab"
                                      IsSelected="False" />
     
            </telerik:RadRibbonBar>


    Thanks for all your help,
    Chris Townsend

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Sep 3, 2011 (permalink)

    Hi Christopher ,

    I posted an answer to the support thread you started, but I will post it here as well in case any one else encounters the same issues:

    This issue is caused by the selection, basically when you add the contextual tabs the first one gets selected by default and that causes an issue with the MinimizedPopup - it cannot be opened. This is an issue that is caused by the current implementation of the RadRibbonBar control.

    As a workaround I handled the RadRibbonBar.PreviewSelectedTabChanged event based on the toolbarPopupLocked flag value. Basically when the contextual tabs are added and the flag is set to True, I handle both the opening of the popup and the change of the selection. Also, I am not aware of your entire scenario and implementation, but you might not need to handle the MouseEnter event. I believe that the toolbarPopupLocked flag can be set to True when adding the ContextualGroup and as soon as you handle the PreviewPopupOpened event, you can set it back to false. I attached a sample project to illustrate a possible implementation of your scenario.

    However, please keep in mind that the RadRibbonBar implementation has many known limitation. This is why we decided that it is best to provide a new implementation of the control. The new RadRibbonView control has pretty much the same API as the RadRibbonBar but it significantly improves its functionality, databinding support and design-time support. And after the official release of the control we started advising all our customers to switch to it as the RibbonBar control support will be discontinued in time.

    However, in your case, unfortunately, for the moment you can't take advantage of the RadRibbonView control as it still doesn't support a scenario where the ContextualTabs are loaded at run-time from code-behind. But this is an issue that we will fix for the upcoming ServicePack release and once the 2011 Q2 SP1 release is out you can give the RibbonView control as it's better to use this control in production code rather than the RadRibbonBar.

    Regards,
    Tina Stancheva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > RibbonBar > Collapsing RadRibbonTab minimized popup