コンポーネントのラインナップ:メニュー項目のみbindコマンドパラメータの一

StackOverflow https://stackoverflow.com/questions/3011184

質問

久がこのカップルでの利用の場合メニューのコマンドにより、ダイナミックチェックしてしまっている。私の作成メニューから色んな色にカラム開発を維持-管理。とにかく初めてのメニュー(そのコンテキストメニューのコマンドパラメータの結合に起こるもので、冠をかぶせる必要がありカラムのコンテキストメニューを開設します。ただし、次の時間を持って行くというコンポーネントのラインナップのキャッシュのメニューズでrebindのコマンドパラメータとします。りできますので設定色のみの初期の列のコンテキストメニューが登場します。

私はかつてこの状況は過去のメニューに完全に動的破壊の場合、メニューを閉じないよう再建ので、あまりないと思いますようにこのhack.もっとよりよい。

    <MenuItem
       Header="Colour"
       ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ResultEditorGrid}}, Path=ColumnColourCollection}"
       ItemTemplate="{StaticResource colourHeader}" >
       <MenuItem.Icon>
          <Image
             Source="{StaticResource ColumnShowIcon16}" />
       </MenuItem.Icon>
       <MenuItem.ItemContainerStyle>
          <Style
             TargetType="MenuItem"
             BasedOn="{StaticResource systemMenuItemStyle}">
             <!--Warning dont change the order of the following two setters
                                otherwise the command parameter gets set after the command fires,
                                not mush use eh?-->
             <Setter
                Property="CommandParameter">
                <Setter.Value>
                   <MultiBinding>
                      <MultiBinding.Converter>
                         <local:ColumnAndColourMultiConverter/>
                      </MultiBinding.Converter>
                      <Binding RelativeSource="{RelativeSource AncestorType={x:Type DataGridColumnHeader}}" Path="Column"/>
                      <Binding Path="."/>
                   </MultiBinding>
                </Setter.Value>
             </Setter>
             <Setter
                Property="Command"
                Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ResultEditorGrid}}, Path=ColourColumnCommand}" />
          </Style>
       </MenuItem.ItemContainerStyle>
    </MenuItem>
役に立ちましたか?

解決

問題はContextMenuの 話を聞いてみると、どうやらルートのツリーの視覚 を読んでどこかがかかっている"とのdatacontextその親会社が一度だけの船積みなので、親のdatacontextの変更をチェックボックス以外の設定が死なない。(残念ながらできないリンクをためる)

またこの問題を前に、私が行った利用 ジ-スミスのバーチャルパターン支店.かなり技術的なものにしたかったんでどれが分かったような気がしましたこのツリーの視覚ナンセンスです。

基本的に作成するこの橋梁を結合するの観光スポットの拠点にdatacontext.のアイコンをクリックの作成 として、静的リソース, を可能にし、結合してからコンテキストメニューの場合でも外部の映像ます。

追加することのできるー:

<Window.Resources>
   <!-- This is the "root node" in the virtual branch
   attached to the logical tree. It has its
   DataContext set by the Binding applied to the
   Window's DataContext property. -->
   <FrameworkElement x:Key="DataContextBridge" />
</Window.Resources>

<Window.DataContext>
   <!-- This Binding sets the DataContext on the "root node"
   of the virtual logical tree branch.  This Binding
   must be applied to the DataContext of the element
   which is actually assigned the data context value. -->
   <Binding
    Mode="OneWayToSource"
    Path="DataContext"
    Source="{StaticResource DataContextBridge}"
   />
</Window.DataContext>

本橋さん。これに対して、datacontextおよび__押しit_への橋datacontextは、先ほど述べたように)静的なリソースです。

見つかればそこにcontextmenuのdatacontext:

 DataContext="{Binding
               Source={StaticResource DataContextBridge},
               Path=DataContext}"

今捨てすべての相対的なpathing等の使用通常の結合を内部のメニュー項目だきます。のdatacontext更新となります。

一つだけ注

まで明らかにして、datacontextが見えるコマンドを使っていらっしゃることだと思いますることができます。このソリューションでお得にcontextmenuのほ更新

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top