Files
aistudio-wpf-diagram/Dragablz/DragablzDemo/CustomHeader.xaml
2021-07-23 09:42:22 +08:00

44 lines
2.1 KiB
XML

<UserControl x:Class="DragablzDemo.CustomHeader"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dragablzDemo="clr-namespace:DragablzDemo"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
d:DataContext="{d:DesignInstance dragablzDemo:CustomHeaderViewModel, IsDesignTimeCreatable=False}">
<!--
Illustrates how to add a custom header, without completely rewriting the DragablzItem header template.
Note that rewriting the DragablzItem header template is a perfectly valid thing to do, but this allows
customisation of existing templates.
-->
<UserControl.Resources>
<Style TargetType="{x:Type Thumb}" x:Key="InvisibleThumbStyle">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<StackPanel Orientation="Horizontal">
<Grid>
<TextBlock Text="{Binding Header}" />
<!-- you should provide your own Thumb, which will be used to monitor dragging -->
<Thumb Style="{DynamicResource InvisibleThumbStyle}"
dragablz:DragablzItem.IsCustomThumb="True" />
</Grid>
<CheckBox IsChecked="{Binding IsSelected}" ToolTip="Embed your own controls" />
<Button ToolTip="Manually add a close button"
Command="dragablz:TabablzControl.CloseItemCommand"
>X</Button>
</StackPanel>
</UserControl>