WPF 中的自定义 tabited.header 样式
本文关键字:header 样式 tabited 自定义 WPF | 更新日期: 2023-09-27 18:36:18
我想只在tabcontrol
的标题中使用图片。我像这样使用:
<TabItem.Header>
<Image Name="ImageClientPoints" Width="150" Height="80"
Stretch="Fill" Margin="0,0,0,0" />
</TabItem.Header>
结果如下:
http://oi39.tinypic.com/x3hnc9.jpg
但我只想要图片,而图片周围没有灰色内容。
我是 wpf 的新手,我读过它,因为我知道我必须为此创建一个datatemplate
,但这对我来说还很难,一个例子会有所帮助。
你快到了。似乎标题保留了某种填充。因此,set the margin value to some negative value
重叠该填充空间。
这将为你做 -
<TabItem.Header>
<Image Name="ImageClientPoints" Width="150" Height="80"
Stretch="Fill" Margin="-5" />
</TabItem.Header>
或
<TabItem.HeaderTemplate>
<DataTemplate>
<Image Name="ImageClientPoints" Width="150" Height="80"
Stretch="Fill" Margin="-5" />
</DataTemplate>
</TabItem.HeaderTemplate>