Jak zdefiniować wspólny styl dla TextBox i pola PasswordBox?Typowy styl dla pól hasła i TextBox
Moje podejście, mam zdefiniować styl dla TargetType FrameworkElement, ale to nie działa jako typowy styl, a następnie kilka właściwości nie istnieje na FrameworkElement.
Moje TextBox Style jest równa 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>
Style Property "PasswordBoxSpecProperty" doesnt znaleźć w "System.Windows.Controls.PasswordBox" to samo dla "ControlProperty" "System.Windows.Controls.Control" i "TextboxSpecproperty" "System.Windows.Controls.TextBox" –
ah lol, okej Rozumiem ... rozwiązałem ... TextBox.MinHeight thx:) –
@MarioBinder Jak rozwiązałeś błąd dotyczący właściwości? Mam ten sam problem. Czy nie powinienem wstawić właściwości stylu do pliku App.xaml? W katalogu zasobów ..... – Tarek