1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
<Window x:Class="WpfExpanderTabItem.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfExpanderTabItem"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<local:Persons x:Key="src"/>
<DataTemplate x:Key="style" DataType="{x:Type local:Person}">
<Border
Name="Border"
CornerRadius="2,0,0,0"
Background="Transparent"
BorderBrush="{StaticResource NormalBorderBrush}"
BorderThickness="0,0,1,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" ></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Path
Grid.Column="0"
Name="Arrow"
Fill="DarkSlateBlue"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 0 0 L 4 4 L 8 0 Z">
</Path>
<ToggleButton
x:Name="toggle"
Grid.Column="1"
Margin="5"
Background="Tan"
Content="{Binding Path=Nom}">
<!--<ToggleButton.Content>
<Binding Path="ContentSource">
<Binding.RelativeSource>
<RelativeSource AncestorType="{x:Type ContentPresenter }" />
</Binding.RelativeSource>
</Binding>
</ToggleButton.Content>-->
<ToggleButton.IsChecked>
<Binding Path="IsSelected">
<Binding.RelativeSource>
<RelativeSource AncestorType="{x:Type TabItem}" Mode="FindAncestor" />
</Binding.RelativeSource>
</Binding>
</ToggleButton.IsChecked>
</ToggleButton>
</Grid>
</Border>
<DataTemplate.Triggers>
<Trigger SourceName="toggle" Property="IsChecked" Value="true">
<Setter
TargetName="Arrow" Property="Path.Data"
Value="M 0 4 L 4 0 L 8 4 Z" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</Window.Resources>
<Grid>
<TabControl
Margin="5" TabStripPlacement="Left"
ItemsSource="{Binding Source={StaticResource src}}"
ItemTemplate="{StaticResource style}">
<!-- Change ItemTemplate to control content on tabs -->
<!-- Change ContentTemplate to control main content -->
<TabControl.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding Memo}"/>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</Grid>
</Window> |
Partager