Come è possibile definire uno stile comune per il controllo TextBox e PasswordBox?Stile comune per PasswordBox e TextBox
Il mio approccio, ho definito uno stile per TargetType FrameworkElement ma questo non funziona come stile comune, quindi non esistono poche proprietà su FrameworkElement.
My Style TextBox è uguale al PasswordBoxStyle
<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>
Stile di proprietà "PasswordBoxSpecProperty" che si trova in "System.Windows.Controls.PasswordBox" lo stesso per "ControlProperty" "System.Windows.Controls.Control" e "TextboxSpecproperty" "System.Windows.Controls.TextBox" –
ah lol, ok capisco .. ho risolto ... TextBox.MinHeight thx:) –
@MarioBinder come hai risolto l'errore relativo alle proprietà? Ho lo stesso problema. Non dovrei inserire la proprietà style in App.xaml? In una directory di risorse ..... – Tarek