我不知道我想做的事情是否可能......
但我正在尝试的是在UserControl
和TabHeader
之间添加TabContent
,但我无法按照我的意愿添加保证金。
这是我Styler
Tab-Control
<Style x:Key="TabItemStyle" TargetType="{x:Type TabItem}">
<Setter Property="FontFamily" Value="Trebuchet MS"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Foreground" Value="#FFFFFFFF"/>
<Setter Property="Header" Value="{Binding Content.DataContext.HeaderInfo, RelativeSource={RelativeSource Self}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid Width="Auto" Height="Auto" x:Name="TabItemRoot" Margin="10,0,5,0">
<ContentPresenter Margin="10,5,0,5" x:Name="Content" ContentSource="Header" RecognizesAccessKey="True"/>
<Border x:Name="border" Height="Auto" Padding="0,0,0,0" Opacity="0">
<Border.Background>
<RadialGradientBrush>
<GradientStop Color="#A3FFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="1"/>
</RadialGradientBrush>
</Border.Background>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="border" Property="Opacity" Value="1"/>
<Setter TargetName="Content" Property="Opacity" Value="1"/>
</Trigger>
<Trigger Property="IsSelected" Value="false">
<Setter TargetName="Content" Property="Opacity" Value="0.5"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
每当我设置边距时,它会移动内容而不是控件。
答案 0 :(得分:0)
您可能希望为TabControl定义ControlTemplate,而不仅仅是对于具有以下内容的项目:
<TabControl>
<TabControl.Style>
<Style TargetType="TabControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabControl">
<StackPanel>
<TabPanel IsItemsHost="True" />
<Border Margin="10" BorderBrush="Blue" Background="Green" Width="100" Height="100" />
<ContentPresenter ContentSource="SelectedContent" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</TabControl.Style>
修改强> 我仍然没有真正得到你想做的事情,但是要在TabHeader和TabContent之间放置任何东西,你可以想出像TabItems的模板这样的东西:
<ControlTemplate TargetType="TabItem">
<Border BorderBrush="Black" BorderThickness="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<ContentPresenter ContentSource="Header" Grid.Row="0" />
<TextBlock Grid.Row="1">Usercontrol goes here</TextBlock>
</Grid>
</Border>
</ControlTemplate>