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
}
}