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

QAT and Backstage buttons not working

3 Answers 161 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 1
Gary asked on 22 Aug 2011, 01:03 AM
I'm somewhat new to WPF so I could just be doing something stupid - if so please forgive me.
I'm trying to use the RadRibbonView control to display a QAT and backstage menu and I've bound the typical Save, Open, New, etc. buttons to a Command which I've set up to call a CanExecute and Executed event in the code behind of my application. The problem I'm having is that whenever I navigate to the backstage all of the QAT buttons become disabled (despite my configuring them to always be enabled) and *some* of the buttons in the backstage don't work (they show as enabled but some of them just don't call the Executed handler). I've been pulling my hair out trying to figure out what's going on and I'm getting nowhere with it. I've posted a sample app that reproduces the issue to my site: http://www.falchionconsulting.com/wpfribbontest.zip. Here's the core pieces of code that you'll see in there:

Update: I found that if I have CloseOnClick="False" for the RadRibbonBackstageItem button then the event fires but the QAT buttons are still disabled (and of course the backstage is still visible).

MainWindow.xaml:
<telerik:RadRibbonWindow x:Class="WpfRibbonTest.MainWindow" xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.RibbonView" Title="Ribbon Test" Height="350" Width="525" >

<Window.CommandBindings>

<CommandBinding Command="ApplicationCommands.Close" CanExecute="CloseButton_CanExecute" Executed="CloseButton_Executed" />

<CommandBinding Command="ApplicationCommands.Save" CanExecute="SaveButton_CanExecute" Executed="SaveButton_Executed" />

<CommandBinding Command="ApplicationCommands.SaveAs" CanExecute="SaveAsButton_CanExecute" Executed="SaveAsButton_Executed" />

<CommandBinding Command="ApplicationCommands.Open" CanExecute="OpenButton_CanExecute" Executed="OpenButton_Executed" />

<CommandBinding Command="ApplicationCommands.New" CanExecute="NewButton_CanExecute" Executed="NewButton_Executed" />

</Window.CommandBindings>

 

<Grid>

<Grid.RowDefinitions>

<RowDefinition Height="Auto"></RowDefinition>

<RowDefinition></RowDefinition>

</Grid.RowDefinitions>

<telerik:RadRibbonView Grid.Row="0" ApplicationButtonContent="File" IsBackstageOpen="False" x:Name="ribbon" ApplicationName="App Name" Title="App Title">

<telerik:RadRibbonView.QuickAccessToolBar>

<telerik:QuickAccessToolBar>

<telerik:RadRibbonButton Text="New" Size="Small" SmallImage="Icons/Icon.ico" Command="ApplicationCommands.New" />

<telerik:RadRibbonButton Text="Open" Size="Small" SmallImage="Icons/Open.png" Command="ApplicationCommands.Open" />

<telerik:RadRibbonButton Text="Save" Size="Small" SmallImage="Icons/Save.ico" Command="ApplicationCommands.Save" />

</telerik:QuickAccessToolBar>

</telerik:RadRibbonView.QuickAccessToolBar>

<telerik:RadRibbonView.Backstage>

<telerik:RadRibbonBackstage>

<telerik:RadRibbonBackstageItem Header="New" Icon="Icons/New.png" IsSelectable="False" Command="ApplicationCommands.New" />

<telerik:RadRibbonBackstageItem Header="Open" Icon="Icons/Backstage/Open.png" IsSelectable="False" Command="ApplicationCommands.Open" />

<telerik:RadRibbonBackstageItem CloseOnClick="False" Header="Save" Icon="Icons/Backstage/Save.png" IsSelectable="False" Command="ApplicationCommands.Save" />

<telerik:RadRibbonBackstageItem Header="Save As" Icon="Icons/Backstage/SaveAs.png" IsSelectable="false" Command="ApplicationCommands.SaveAs" />

<telerik:RadRibbonBackstageItem Header="Separator" IsGroupSeparator="True" />

<telerik:RadRibbonBackstageItem Header="Exit" Icon="Icons/Backstage/Exit.png" IsSelectable="False" Command="ApplicationCommands.Close" />

</telerik:RadRibbonBackstage>

</telerik:RadRibbonView.Backstage>

<telerik:RadRibbonTab Header="Home" x:Name="homeTab">

<telerik:RadRibbonGroup Header="Group 1">

<telerik:RadRibbonGroup.Variants>

<telerik:GroupVariant Variant="Large" Priority="1" />

</telerik:RadRibbonGroup.Variants>

</telerik:RadRibbonGroup>

</telerik:RadRibbonTab>

</telerik:RadRibbonView>

</Grid>

</telerik:RadRibbonWindow

 

 

 

Codebehind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
 
namespace WpfRibbonTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : RadRibbonWindow
    {
        public static RoutedCommand OpenMruFileCommand = new RoutedCommand();
 
        public MainWindow()
        {
            InitializeComponent();
        }
 
        #region New Menu Event Handler
 
        private void NewButton_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }
 
        private void NewButton_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            NewFile();
        }
 
        private void NewFile()
        {
            MessageBox.Show("New File called");
        }
 
        #endregion
 
        #region Open Menu Event Handler
 
        private void OpenButton_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }
 
        private void OpenButton_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFile();
        }
 
        private void OpenFile()
        {
            MessageBox.Show("Open File called");
        }
        private void OpenFile(string fileName)
        {
            MessageBox.Show("Open File called (" + fileName + ")");
        }
 
 
        #endregion
 
        #region Save Menu Event Handler
 
        private void SaveButton_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }
 
        private void SaveButton_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            SaveFile(false);
        }
 
        private void SaveAsButton_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }
 
        private void SaveAsButton_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            SaveFile(true);
        }
 
 
        private void SaveFile(bool saveAs)
        {
            MessageBox.Show("Save File called (SaveAs=" + saveAs + ")");
        }
 
        #endregion
 
 
        #region Close Button Event Handler
 
        private void CloseButton_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }
 
        private void CloseButton_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("Close App called");
        }
 
 
        #endregion
    }
}

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 24 Aug 2011, 04:46 PM
Hi Gary,

 I'm glad that you have found how to use the Commands in the BackStageItems. As for the QAT issue, this behavior is expected and it is strictly written in the MS's Guidelines Document that is used when designing the RadRibbonView. However, we prepared a feature request in our PITS and you can vote for it in order to increase its development priority. Feel free to ask if you need further questions.

Greetings,
Petar Mladenov
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 >>

0
Gary
Top achievements
Rank 1
answered on 24 Aug 2011, 05:52 PM
Thanks for the reply. I'm a bit confused though - the QAT buttons become disabled when I go to the backstage, that I expect and understand. The problem is that they stay disabled when I leave the backstage and return to my home tab.
0
Petar Mladenov
Telerik team
answered on 29 Aug 2011, 03:25 PM
Hi Gary,

 We agree that this is a bug in the RadRibbonView. We logged it in our PITS(RibbonView: QAT buttons do not work correctly with ApplicationCommands) where it will be soon published. We'll do our best to have this fixed for the Q2 Service Pack 1 scheduled for the middle of September. We also updated your telerik account points. Thank you for your cooperation.

Kind regards,
Petar Mladenov
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 >>

Tags
RibbonView and RibbonWindow
Asked by
Gary
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Gary
Top achievements
Rank 1
Share this question
or