TextBox ve PasswordBox için ortak bir stili nasıl tanımlayabilirim?PasswordBox ve TextBox için Ortak Stil
Benim yaklaşımım, TargetType FrameworkElement için bir Stil tanımladım, ancak bu genel stil olarak çalışmıyor, sonra FrameworkElement üzerinde az sayıda öntanım yok. Benim TextBox Stili olan
<Style TargetType="{x:Type TextBox}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="MinHeight" Value="30"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="FontFamily" Value="Verdana"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border Name="Border" CornerRadius="4" Padding="2" Background="White" BorderBrush="Black" BorderThickness="1" >
<ScrollViewer Margin="0" x:Name="PART_ContentHost"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Stil Mülkiyet "PasswordBoxSpecProperty" doesnt gibi bir şey deneyin PasswordBoxStyle eşittir "ControlProperty" için "System.Windows.Controls.Control" ve "TextboxSpecproperty" "System.Windows.Controls.TextBox" için aynı –
ah lol, tamam anladım .. çözdüm ... TextBox.MinHeight thx:) –
@MarioBinder özellikleriyle ilgili hatayı nasıl çözdün? Aynı problemim var. Stil özelliğini App.xaml içine koymalı mıyım? Bir kaynak dizinde ..... – Tarek