Windows 7 and WPF Ribbon Errors - Application Menu

Nov 17, 2009 at 6:35 PM

I moved a WPF Ribbon project from Windows XP/Visual Studio 2008 to a Windows 7/Visual Studio 2008 machine.  There are no project errors on the Windows XP/VS2008 machine.  However when you run the project on Windows 7/VS2008 you receive the following error when the project loads:

System.Windows.Data Error: 39 : BindingExpression path error: 'CaptionButtonsReservedWidth' property not found on 'object' ''Window1' (Name='MainWindow')'. BindingExpression:Path=CaptionButtonsReservedWidth; DataItem='Window1' (Name='MainWindow'); target element is 'ContentControl' (Name='windowButtonPlaceHolder'); target property is 'Width' (type 'Double')

When you hover over the Application Button the following error appears and Events on the Appication Button do not fire:

System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='Stop'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='13842929'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='Microsoft.Windows.Controls.Ribbon.RibbonApplicationMenu Items.Count:6'; TargetElement.HashCode='30689205'; TargetElement.Type='Microsoft.Windows.Controls.Ribbon.RibbonApplicationMenu'

Is there something additional that needs to be done for Windows 7 compatibility?


As a secondary test, I also created a new C# project on Windows 7/Visual Studio 2008 and added a very basic Ribbon code (see below).  If you apply the 2007 Office Theme: 
<ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml"/>

You receive the error when you hover over or click on the Application button:

System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='Stop'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='13842929'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='Microsoft.Windows.Controls.Ribbon.RibbonApplicationMenu Items.Count:6'; TargetElement.HashCode='30689205'; TargetElement.Type='Microsoft.Windows.Controls.Ribbon.RibbonApplicationMenu'

If you do not apply an Office theme or any theme and simply accept the Windows 7 default you do not receive the errors and the Events on the application button work. 

Is there a way to resolve this issue on Windows 7 and continue to use the Office themes?  Here's the sample xaml code:


<r:RibbonWindow x:Class="MyApp.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
    Title="Window1" Height="300" Width="300" Loaded="RibbonWindow_Loaded" >
    <r:RibbonWindow.Resources  >
        <ResourceDictionary >
             <ResourceDictionary.MergedDictionaries >
                <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <r:RibbonCommand
              x:Key="NewCommand"
              CanExecute="RibbonCommand_CanExecute"
              Executed="RibbonCommand_Executed"
              LabelTitle="New"
              ToolTipDescription="Create New Record."
              ToolTipTitle="New record."  />
            <r:RibbonCommand x:Key="Query" LabelTitle="Query"/>
        </ResourceDictionary>
    </r:RibbonWindow.Resources>
    <Grid >
        <r:Ribbon Grid.Row="1" Title="MyApp" x:Name="MyRibbon" >
            <r:Ribbon.ApplicationMenu >
                <r:RibbonApplicationMenu>
                    <r:RibbonApplicationMenu.Command >
                        <r:RibbonCommand Executed="RibbonCommand_Executed"
                        LabelTitle="Home"
                        ToolTipDescription="Home Button"
                        ToolTipTitle="Home Button"  />
                      </r:RibbonApplicationMenu.Command>
                    <r:RibbonApplicationMenu.RecentItemList >
                        <r:RibbonHighlightingList MostRecentFileSelected="RibbonHighlightingList_MostRecentFileSelected_1" ItemsSource="{Binding MostRecentFiles}" DisplayMemberPath="Name" />
                    </r:RibbonApplicationMenu.RecentItemList>
                    <r:RibbonApplicationMenuItem x:Name= "HNew" Command ="{StaticResource NewCommand}" Click="QNew_Click" />
                </r:RibbonApplicationMenu>
            </r:Ribbon.ApplicationMenu>
            <r:RibbonTab Name="QueryTab" Label="Query" Selected="TabChange"  >
                <r:RibbonGroup Name="QrgQuery" Command="{StaticResource Query}" >
                    <r:RibbonLabel Content="Search by:"></r:RibbonLabel>
                </r:RibbonGroup>
            </r:RibbonTab>
        </r:Ribbon>
    </Grid>
    </r:RibbonWindow>