私はカスタムRoutedUICommandを作成するのに、thisの記事と他の記事をたどりました。 Infragistics Ribbonを使用していますが、そこから問題が発生するとは思われません。xamlでカスタムRoutedUICommandを使用すると例外がスローされます
<igRibbon:XamRibbonWindow x:Class="MyRibbonWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:igRibbon="http://infragistics.com/Ribbon"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:MyNamespaceTag="clr-namespace:MyNamespace"
xmlns:igWPF="http://schemas.infragistics.com/xaml/wpf" mc:Ignorable="d"
WindowState="Maximized">
<igRibbon:XamRibbonWindow.Resources>
<!-- Some DataTempaltes here -->
</igRibbon:XamRibbonWindow.Resources>
<igRibbon:RibbonWindowContentHost x:Name="ribbonWindowContentHost" >
<igRibbon:RibbonWindowContentHost.Ribbon>
<igRibbon:XamRibbon x:Name="xamRibbon" Theme="[current]">
<igRibbon:XamRibbon.ApplicationMenu>
<igRibbon:ApplicationMenu>
<igRibbon:ApplicationMenu.FooterToolbar>
<igRibbon:ApplicationMenuFooterToolbar>
<igRibbon:ButtonTool Name="appMenuOptions" Caption="Opt_ions"/>
</igRibbon:ApplicationMenuFooterToolbar>
</igRibbon:ApplicationMenu.FooterToolbar>
</igRibbon:ApplicationMenu>
</igRibbon:XamRibbon.ApplicationMenu>
</igRibbon:XamRibbon>
</igRibbon:RibbonWindowContentHost.Ribbon>
<ContentControl Content="{Binding MyContent}"
ContentTemplateSelector="{StaticResource myContentTemplateSelector}" />
</igRibbon:RibbonWindowContentHost>
</igRibbon:XamRibbonWindow>
私たちは、インフラジスティックスリボンのルックアンドフィールを変更するために必要な、とインフラジスティックスの地域コミュニティからのチームメンバーが追加されるスタイルを提案しました。問題は、リボンのResourcesセクションに追加したときにうまくいかないことです。 は、だから我々は、次の操作を行うことを余儀なくされた。
var resourceDictionary = new ResourceDictionary();
resourceDictionary.Source = new Uri(
@"/MyNamespace;component/Resources/RibbonResources.xaml",
UriKind.RelativeOrAbsolute);
xamRibbon.Resources.MergedDictionaries.Add(resourceDictionary);
これは正しくリボンでスタイルが適用されますが、そのRibbonResources.xamlに、我々はボタンがあります、
<Button Name="myButton"
Command="MyNamespaceTag:MyCommands.MyCommand"
Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
<Image Source="MyImage.png" Width="16" Height="16" />
</Button>
MyCommandとMyCommandsクラスを私が述べた記事とまったく同じように作成されています。 しかし、私は、私は次のエラーを取得するアプリケーションを実行すると:
XamlParseException: Failed to create a 'Command' from the text MyNamespace:MyCommands.MyCommand' InnerException: Type reference cannot find type named '{clr-namespace:MyNamespace}MyCommands'.
を私が代わりに、このようなコマンドを使用している場合:で
XamlParseException: Provide value on 'System.Windows.Markup.StaticExtension' threw an exception. InnerException: Type reference cannot find type named '{clr-namespace:MyNamespaces}MyCommands'.
:
Command="{x:Static MyNamespaceTag:MyCommands.MyCommand}"
私は次の例外を取得しますコードビハインドは次のようなコマンドをバインドしています:
CommandBindings.Add(
new CommandBinding(
MyCommands.MyCommand,
Show,
CanShow));
ボタンをXamRibbonWindowのある場所に直接配置すると、正常に動作します。
私はまだWPFでかなり新しいです。私が間違っていることを理解できません。
私が使用している実際のネームスペースはシェルですが、読みやすくするためにシェルを作成したときにMyNamespaceを書きました。私はちょうどその場所を逃した。私はそれに応じてそれを編集します。 – Dzyann