私の DataTemplate (ClosableTabItemTemplate) を Relative Source で HeaderedContentControl の Workspaces DataContext にバインドしたいと思います。残念ながらうまくいきませんか?何か案は?
ところで: 次のコマンド ライン エラーが発生します: System.Windows.Data Error: 40 : BindingExpression path error: 'DisplayName' プロパティが 'object' ''AllUserView' (Name='')' に見つかりません。BindingExpression:Path=DataContext.DisplayName; DataItem='TabItem' (Name=''); ターゲット要素は 'ContentPresenter' (Name='') です。ターゲット プロパティは「コンテンツ」(タイプ「オブジェクト」)
シア・マイケル
<HeaderedContentControl
Content="{Binding Path=Workspaces}"
ContentTemplate="{StaticResource WorkspacesTemplate}"
Header=""
Style="{StaticResource MainHCCStyle}" DataContext="{Binding}"
/>
<DataTemplate x:Key="ClosableTabItemTemplate">
<DockPanel Width="120" >
<Button
Command="{Binding Path=DataContext.CloseCommand, RelativeSource={RelativeSource AncestorType={x:Type HeaderedContentControl}}}"
Content="X"
Cursor="Hand"
DockPanel.Dock="Right"
Focusable="False"
FontFamily="Courier"
FontSize="9"
FontWeight="Bold"
Margin="0,1,0,0"
Padding="0"
VerticalContentAlignment="Bottom"
Width="16" Height="16"
/>
<ContentPresenter
Content="{Binding Path=DataContext.DisplayName, RelativeSource={RelativeSource AncestorType={x:Type HeaderedContentControl}}}"
VerticalAlignment="Center"
/>
</DockPanel>
</DataTemplate>
<DataTemplate x:Key="WorkspacesTemplate">
<TabControl
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding}"
ItemTemplate="{StaticResource ClosableTabItemTemplate}"
Margin="4"
/>
</DataTemplate>