在Blend中製作了一個漂亮的標籤,但我的ContentPresenter
必須關閉 - 它不顯示TabItem
標題文本。TabItem樣式不顯示標題信息
編輯1:實現了CodeNaked的建議和Rachel的答案,所以如果你喜歡,你可以直接使用這種風格。
<Style x:Key="TabItemStyle2" TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Border BorderThickness="3" CornerRadius="5,5,0,0">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#7F605F5F" Offset="0"/>
<GradientStop Color="#7F7E7E7E" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF6096E5" Offset="0.004"/>
<GradientStop Color="#FF6096E5" Offset="0.823"/>
<GradientStop Color="White" Offset="0.228"/>
</LinearGradientBrush>
</Border.Background>
</Border>
<Border x:Name="BorderGlass" BorderThickness="3" CornerRadius="5,5,0,0" Background="#7FFDFDFD">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#7FFFFFFF" Offset="0"/>
<GradientStop Color="#BFFFFFFF" Offset="0.401"/>
<GradientStop Color="#F2FFFFFF" Offset="0.254"/>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<ContentPresenter HorizontalAlignment="Center" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" ContentPresenter ContentSource="Header">
<ContentPresenter.OpacityMask>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF6096E5" Offset="0"/>
<GradientStop Color="#FF6096E5" Offset="0.823"/>
<GradientStop Color="White" Offset="0.228"/>
</LinearGradientBrush>
</ContentPresenter.OpacityMask>
</ContentPresenter>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
你可以添加一些關於如何使用這種風格的代碼嗎? – MoonKnight