سلام بر تمامی برنامه نویسان سی شارپ 😉 در این مطلب کد قرار دادن border برای ToolTip با ControlTemplate با wpf و سی شارپ #C را آماده کردم. امیدوارم که این کد برای شما مفید باشد.
خروجی این کد:
کد قرار دادن border برای ToolTip با ControlTemplate با wpf و سی شارپ #C :
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="160" Width="300">
<Window.Resources>
<Style TargetType="{x:Type ToolTip}">
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="100"/>
<Setter Property="HasDropShadow" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="{x:Type ToolTip}">
<Border Name="Border"
BorderBrush="DarkGray"
BorderThickness="1"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
CornerRadius="4">
<Border.Background>
<LinearGradientBrush
StartPoint="0,0"
EndPoint="0,1">
<GradientStop
Color="Snow"
Offset="0.0"/>
<GradientStop
Color="Gainsboro"
Offset="1.0"/>
</LinearGradientBrush>
</Border.Background>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="160" Width="300">
<Window.Resources>
<Style TargetType="{x:Type ToolTip}">
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="100"/>
<Setter Property="HasDropShadow" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="{x:Type ToolTip}">
<Border Name="Border"
BorderBrush="DarkGray"
BorderThickness="1"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
CornerRadius="4">
<Border.Background>
<LinearGradientBrush
StartPoint="0,0"
EndPoint="0,1">
<GradientStop
Color="Snow"
Offset="0.0"/>
<GradientStop
Color="Gainsboro"
Offset="1.0"/>
</LinearGradientBrush>
</Border.Background>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>