控件效果如下:
该用户控件的显示样式代码在XAML页面,功能实现代码在后台.CS页面,在XAML页面的样式代码如下:
<TabItem x:Class="WPF_Client.Resources.Controls.UCTabItemWithClose"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="TabItem_Loaded">
<!--定义资源-->
<TabItem.Resources>
<!--按钮样式:用x:Key设置唯一键-->
<Style x:Key="CloseButtonStyle" TargetType="{x:Type Button}">
<!--边框:白色-->
<Setter Property="BorderBrush" Value="White"></Setter>
<!--背景:#de4751-->
<Setter Property="Background" Value="#de4751"></Setter>
<Setter Property="Template">
<Setter.Value>
<!--自定义模板-->
<ControlTemplate TargetType="{x:Type Button}">
<!--定义视觉树-->
<Grid>
<!--形状绘图:椭圆-->