سلام 😉 در این مطلب از وب سایت پروگرم 98 کد قرار دادن ControlTemplate درون Style با wpf و سی شارپ #C را آماده کردم. امیدوارم که این کد برای شما مفید باشد.
تصاویر خروجی نهایی این کد:
کد قرار دادن ControlTemplate درون Style با 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="120" Width="260">
<Window.Resources>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Width" Value="36"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate
TargetType="{x:Type ToggleButton}">
<Canvas >
<Path x:Name="pth" Stroke=''''"3" StrokeStartLineCap="Round"
StrokeEndLineCap="Round" StrokeLineJoin="Round"
Data="M 10,100 l 100,0 l 18,-10 l 5,110 l 10,0 l -7,110 l 2,210 l -20,-15 l -110,5 l 2,-110 Z" />
</Canvas>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="120" Width="260">
<Window.Resources>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Width" Value="36"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate
TargetType="{x:Type ToggleButton}">
<Canvas >
<Path x:Name="pth" Stroke=''''"3" StrokeStartLineCap="Round"
StrokeEndLineCap="Round" StrokeLineJoin="Round"
Data="M 10,100 l 100,0 l 18,-10 l 5,110 l 10,0 l -7,110 l 2,210 l -20,-15 l -110,5 l 2,-110 Z" />
</Canvas>