WPF Ribbon Changing Theme
Hi I am creating my first WPF application that uses Ribbons. The problem I am having is I cannot change the theme of the ribbons. I want to use the Office 2007 Black theme. I have looked everywhere and everywhere I fi开发者_开发技巧nd roughly the same example, I have tried writing it from scratch, copy pasting and everything but it keeps throwing an exception when I try t run the application.
Exception
Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '11' and line position '18'.
Inner Exception
{"Cannot locate resource 'themes/office2007black.xaml'."}
Xaml Code
<r:RibbonWindow x:Class="DtcInvoicer.MainWindow"
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="Dtc Invoicer"
Width="1000" Height="650" WindowStartupLocation="CenterScreen">
<r:RibbonWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Black.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</r:RibbonWindow.Resources>
<Grid x:Name="LayoutRoot">
<r:Ribbon x:Name="TopMenuRibbon" Title="First Ribbon">
<r:RibbonTab Header="Home" />
<r:RibbonTab Header="Company" />
<r:RibbonTab Header="Employees" />
<r:RibbonTab Header="Receivables" />
<r:RibbonTab Header="Payables" />
<r:RibbonTab Header="Inventory" />
<r:RibbonTab Header="Settings" />
</r:Ribbon>
</Grid>
</r:RibbonWindow>
Anyone have idea why that might be happening? The RibbonControlsLibrary is in my references, everything works fine and the ribbons come up in the blue theme until I try to switch to black or silver, then I get the exception.
Resources that are specific to a theme are kept in a resource dictionary with a specific file name. These files must be in a folder named Themes that is a subfolder of the folder that contains the control.
See this MSDN article for more details.
精彩评论