2010-12-28 13 views
1

私は(のContextMenuのための一例)以下かこれを行うにはExpression Blendの4でのデフォルト設定に基づかれたContextMenuやツールチップのための新しいスタイルを作成したい:WPF:Expression Blend 4でContextMenuまたはツールチップを編集中にエラーが発生しました "論理的または視覚的な親を持つことはできません。

  1. EBlend 4
  2. で新しいWPFアプリケーションを作成します。
  3. ボタンをウィンドウに置きます。
  4. ボタン用の新しいContextMenuを作成します。
  5. ContextMenuに2つのサンプルアイテムを追加します(ヘッダーは「item1」と「item2」)。
  6. "プロパティ"パネルのコンテキストメニューの "スタイル"プロパティのプロパティプロパティで、 "スタイル"プロパティの右側にある四角形をクリックし、 "新しいリソースに変換..."を選択します。
  7. 開いている "スタイルリソースを作成"ウィンドウで "このドキュメント[ウィンドウ:ウィンドウ]"または新しいリソース辞書の "定義済み"を選択します。
  8. 私のメッセージの下部に、このようなContextMenuのデフォルトスタイルのXAMLがあります。
  9. このスタイルをプレビューで編集したいので、 "リソース"タブに行き、私の "ContextMenuStyle1"を見つけ、右クリックして "編集"を選択してください。
  10. スタイルを編集できません。例外がスローされたという情報があります。 '' ContextMenu 'は論理的または視覚的な親を持つことはできません。 "

さらに、「ResourceDictionary1.xaml」には更新されないエラーが含まれているため、「ResourceDictionary1.xaml」にリソースを追加することはできませんので、他の新しいスタイルを追加することもできません。 " "ResourceDictionary1.xaml"ビューを閉じてから再度開くまで。

誰でも問題を解決し、Expression Blend 4でContextMenuまたはToolTipスタイルを編集する方法を解説し、変更内容を視覚的にプレビューして、すべてのプロパティと機能にアクセスできますか?

のMicrosoft Expression Blendの中 bugは、このリンクを見ています
<Style x:Key="ContextMenuStyle1" TargetType="{x:Type ContextMenu}"> 
    <Setter Property="Background" Value="{DynamicResource MenuBackgroundBrush}"/> 
    <Setter Property="BorderThickness" Value="1"/> 
    <Setter Property="BorderBrush" Value="{DynamicResource WindowBorderBrush}"/> 
    <Setter Property="Template"> 
    <Setter.Value> 
    <ControlTemplate TargetType="{x:Type ContextMenu}"> 
     <Border Uid="Border_93"> 
     <Border.Style> 
     <Style TargetType="{x:Type Border}"> 
     <Setter Property="Tag" Value="{DynamicResource {x:Static SystemParameters.DropShadowKey}}"/> 
     <Style.Triggers> 
      <DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource Self}}" Value="True"> 
      <Setter Property="Background" Value="Transparent"/> 
      <Setter Property="Padding" Value="0,0,5,5"/> 
      <Setter Property="Effect"> 
      <Setter.Value> 
      <DropShadowEffect BlurRadius="4" Opacity="0.8" ShadowDepth="1"/> 
      </Setter.Value> 
      </Setter> 
      </DataTrigger> 
     </Style.Triggers> 
     </Style> 
     </Border.Style> 
     <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Uid="Border_50"> 
     <ScrollViewer CanContentScroll="True" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}" Uid="ScrollViewer_9"> 
     <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Uid="ItemsPresenter_5"/> 
     </ScrollViewer> 
     </Border> 
     </Border> 
    </ControlTemplate> 
    </Setter.Value> 
    </Setter> 
    </Style> 

答えて

関連する問題