1

Visual Studio 11 で .NET 4.5 を使用して WPF アプリケーションをビルドすると、Visual Studio で奇妙なエラーが発生します。

私の WPF XAML マークアップは次のとおりです。

<RibbonWindow x:Class="Fablelane.DesktopApplication.CreateStory"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Create new story" Height="468" Width="526">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Ribbon>
            <Ribbon.ApplicationMenu>
                <RibbonApplicationMenu>
                </RibbonApplicationMenu>
            </Ribbon.ApplicationMenu>
            <RibbonTab Margin="0" Header="Format">
                <RibbonGroup Header="Font">
                    <StackPanel Orientation="Horizontal">
                        <RibbonComboBox>
                            <RibbonGallery SelectedValue="Heading 1"
                          SelectedValuePath="Content"
                          MaxColumnCount="1">
                                <RibbonGalleryCategory>
                                    <RibbonGalleryItem Content="Heading 1" Foreground="#16ea00" FontSize="20" />
                                    <RibbonGalleryItem Content="Heading 2" Foreground="#00c6ff" FontSize="18" />
                                    <RibbonGalleryItem Content="Heading 3" Foreground="#999999" FontSize="16" />
                                    <RibbonGalleryItem Content="Heading 3" Foreground="#707070" FontSize="14" />
                                    <RibbonGalleryItem Content="Content" Foreground="#FF606060" />
                                </RibbonGalleryCategory>
                            </RibbonGallery>
                        </RibbonComboBox>
                    </StackPanel>
                    <RibbonControlGroup Margin="2">
                        <RibbonToggleButton Label="B"
    FontWeight="Bold" FontFamily="Times New Roman" Padding="2" />
                        <RibbonToggleButton Label="I"
    FontStyle="Italic" FontFamily="Times New Roman" Padding="2" />
                        <RibbonToggleButton Label="U" FontFamily="Times New Roman" Padding="2,2,2,0" />
                    </RibbonControlGroup>
                </RibbonGroup>
            </RibbonTab>
            <RibbonTab Margin="0" Header="Options">
            </RibbonTab>
        </Ribbon>
        <RichTextBox Grid.Row="1">

        </RichTextBox>
    </Grid>
</RibbonWindow>

今、ビルドすると、次のエラーが表示されます。

不明なビルド エラー、アセンブリ 'System.Windows.Controls.Ribbon、Version=4.0.0.0、Culture=neutral、PublicKeyToken=b77a5c561934e089' の 'System.Windows.Controls.Ribbon.RibbonGallery' 型の 'メソッド 'get_Command' にはありません実装。

コードから RibbonGallery 要素を削除すると、コンパイルして正常に実行されます。

デザイナー ビューが Visual Studio で、RibbonGallery 要素を内部に使用して適切にレンダリングされていることを簡単に確認できることに注意してください。ビルド中に失敗するだけです。

4

3 に答える 3

1

私にはバグのように見えます。リフレクターを使用して、ICommand のゲッターが正しく公開されているかどうかを確認してください。

于 2012-04-23T13:35:22.140 に答える
1

問題が見えません。

  • 最新のアップデートを含む VS 11 ベータ版があります。
  • http://www.microsoft.com/en-us/download/details.aspx?id=11877からリボンをダウンロード (2010 年 10 月)
  • 新しい WPF .NET 4.5 アプリを作成する
  • System.Windows.Controls.Ribbon への参照を追加
  • 質問からアプリにコードを貼り付けます
  • 設計、構築、実行、問題なし

DotPeek を使用してリボン アセンブリを見ると、Command プロパティが表示されます。

public ICommand Command
{
  get
  {
    return (ICommand) this.GetValue(RibbonGallery.CommandProperty);
  }
  set
  {
    this.SetValue(RibbonGallery.CommandProperty, (object) value);
  }
}

しかし、あなたはそれを使用していないようです。

新しいテスト アプリをゼロから作成する価値はありますか?

于 2012-04-27T20:36:09.193 に答える