2016-09-08 32 views
1

AvalonDockのタブ(LayoutDocumentPaneGroupとLayoutAnchorablePaneの両方)を選択しようとしています。これは簡単な作業でなければならないようですが、私はその件に関するドキュメントを見つけるのに苦労しています。これまでのところ、最初のタブ(以下を参照)を選択することができましたが、このバインディングは初期ロード後にバインドされたプロパティを変更しても持続しないようです。AvalonDockでタブを選択する方法

<Setter Property="IsSelected" Value="False" /> 
<Style.Triggers> 
    <DataTrigger Binding="{Binding Model.Title}" Value="Resources"> 
     <Setter Property="IsSelected" Value="True" /> 
    </DataTrigger> 
</Style.Triggers> 

::私はこれらの行を交換する場合

<dock:DockingManager Name="DockingManager" Grid.Row="2" 
         AnchorablesSource="{Binding Anchorables}" 
         DocumentsSource="{Binding Documents}" 
         DocumentClosed="DockingManager_DocumentClosed" 
         DocumentClosing="DockingManager_DocumentClosing" 
         Loaded="DockingManager_Loaded" 
         MouseUp="DockingManager_MouseUp"> 
     <dock:DockingManager.LayoutItemContainerStyle> 
      <Style TargetType="{x:Type dockctrl:LayoutItem}" > 
       <Setter Property="Title" Value="{Binding Model.Title}" /> 
       <Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}" /> 
       <Setter Property="CanClose" Value="{Binding Model.CanClose}" /> 
       <Setter Property="IsSelected" Value="False" /> 
       <Style.Triggers> 
        <DataTrigger Binding="{Binding Model.Title}" Value="Resources"> 
         <Setter Property="IsSelected" Value="True" /> 
        </DataTrigger> 
       </Style.Triggers> 
      </Style> 
     </dock:DockingManager.LayoutItemContainerStyle> 

     <dock:LayoutRoot> 
      <dock:LayoutPanel Orientation="Horizontal"> 

       <dock:LayoutAnchorablePaneGroup x:Name="leftAnchorableGroup" DockWidth="300" > 
        <dock:LayoutAnchorablePane /> 
       </dock:LayoutAnchorablePaneGroup> 

       <dock:LayoutPanel Orientation="Vertical"> 
        <dock:LayoutPanel Orientation="Horizontal"> 
         <dock:LayoutDocumentPaneGroup x:Name="leftDocumentGroup"> 
          <dock:LayoutDocumentPane /> 
         </dock:LayoutDocumentPaneGroup> 
        </dock:LayoutPanel> 
       </dock:LayoutPanel> 

      </dock:LayoutPanel> 
     </dock:LayoutRoot> 
    </dock:DockingManager> 

しかし

<Setter Property="IsSelected" Value="{Binding Model.ContentIsSelected" /> 

私はの値がをContentIsSelected変更したとき...それは動作しません。私はの値がですが、自体が実際に変更されていますが、それが変更されていないことを(スヌープを使用して)確認できます。

私はまた、この他の質問(IsSelectedを使用しようとしているのパスを私を導く)が見つかりました:How to switch between document tabs in AvalonDock 2をしかし「プログラム的LayoutItems XAMLでバインディングを超えにアクセスする方法が全く分かりません。私はDockingManager.GetLayoutItemFromModel()関数を試しましたが、NULL以外を返すことができませんでした。

タブを選択してビュー/フォーカスに移動するにはどうすればいいですか(マウスでタブをクリックした場合のように)

答えて

1

解決策は、デフォルトのバインドが期待どおりでなかったことに終わりました。

<Setter Property="IsSelected" Value="{Binding Model.ContentIsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> 
関連する問題