سلام بر برنامه نویسان عزیز ایران زمین 😉 در این مطلب کد استفاده مجدد Style برای TextBox با wpf و #C را آماده کردم. انشاالله که این کد براتون مفید باشه.
تصاویر خروجی نهایی این کد:
کد استفاده مجدد Style برای TextBox با 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="220" Width="300">
<Window.Resources>
<Style x:Key="BaseControlStyle"
TargetType="{x:Type Control}">
<Setter Property="FontFamily" Value="Tahoma" />
<Setter Property="FontSize" Value="24pt"/>
<Setter Property="Margin" Value="4" />
</Style>
<Style TargetType="{x:Type Button}"
BasedOn="{StaticResource BaseControlStyle}">
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style TargetType="{x:Type CheckBox}"
BasedOn="{StaticResource BaseControlStyle}">
</Style>
<Style TargetType="{x:Type TextBox}"
BasedOn="{StaticResource BaseControlStyle}">
</Style>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="220" Width="300">
<Window.Resources>
<Style x:Key="BaseControlStyle"
TargetType="{x:Type Control}">
<Setter Property="FontFamily" Value="Tahoma" />
<Setter Property="FontSize" Value="24pt"/>
<Setter Property="Margin" Value="4" />
</Style>
<Style TargetType="{x:Type Button}"
BasedOn="{StaticResource BaseControlStyle}">
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style TargetType="{x:Type CheckBox}"
BasedOn="{StaticResource BaseControlStyle}">
</Style>
<Style TargetType="{x:Type TextBox}"
BasedOn="{StaticResource BaseControlStyle}">
</Style>