Im Using Composite Aplication Guidiance Pattern for building my WPF application. In my Shell i have a tabcontrol wich contains a region for dynamicly load Views into the region. The views is loaded into new tabs in the TabControl.
<TabControl
AutomationProperties.AutomationId="MainTabControl"
cal:RegionManager.RegionName="{x:Static inf:RegionNames.MainRegion}"
Width="Auto" Height="Auto" Margin="10,10,0,0"
HorizontalAlignment="Stretch"
IsSynchronizedWithCurrentItem="True"
ItemTemplate="{StaticResource TabItemTemplate}"
SelectionChanged="TabControl_SelectionChanged">
I have a DataTemplate "TabItemTemplate" for implementing a CloseButton. I cant figure out how to bind the button´s command in the DataTemplate to the Close Command in the presentationModel. If I bind the command to a CompositCommand, the command is executet. But then I must figure out wich tab that close button was pressed and only execute closeCommand in that PresentationModel.. Below is the dataTemplate.
<DataTemplate x:Key="ClosableTabItemTemplate">
<DockPanel Width="120">
<Button
Command="inf:CloseCommands.CloseCommand"
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}"
VerticalAlignment="Center"
/>
</DockPanel>
</DataTemplate>
Does anyone know how to solve this binding problem??