سلام خدمت کاربران وب سایت پروگرم 98 😉 در این مطلب از وب سایت پروگرم 98 کد Label با ControlTemplate با wpf و سی شارپ را آماده کردم. انشاالله که این کد براتون مفید باشه.
کد Label با ControlTemplate با wpf و سی شارپ :
<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="100" Width="180">
<Window.Resources>
<ControlTemplate x:Key="labelTemplate" TargetType="{x:Type Label}">
<Border x:Name="border" CornerRadius="4" BorderThickness="3" BorderBrush="DarkGray" Background="{TemplateBinding Property=Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="100" Width="180">
<Window.Resources>
<ControlTemplate x:Key="labelTemplate" TargetType="{x:Type Label}">
<Border x:Name="border" CornerRadius="4" BorderThickness="3" BorderBrush="DarkGray" Background="{TemplateBinding Property=Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>