Can't apply a style to TextBox
Posted: 19 Apr 2024, 07:10
Hello there. This code works in Blend, but doesn't in XamlToy/Noesis app.
How to fix it (textBox2)?
How to fix it (textBox2)?
Code: Select all
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
d:DesignHeight="384" d:DesignWidth="285" Width="285" Height="384">
<UserControl.Resources>
<ResourceDictionary>
<Style x:Key="DarkInput" TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="#FF221E22"/>
<Setter Property="BorderBrush" Value="#FF5B5B5B"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="MaxLines" Value="1"/>
<Setter Property="Padding" Value="0"/>
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<StackPanel>
<TextBox x:Name="textBox1" Text="{Binding ValueR}" Height="25" MaxLength="3" Background="#FF221E22" BorderBrush="#FF5B5B5B" Foreground="White" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" MaxLines="1" Margin="0,0,0,10" Padding="0"/>
<TextBox x:Name="textBox2" Text="{Binding ValueR}" Height="25" MaxLength="3" Style="{StaticResource DarkInput}"/>
</StackPanel>
</Grid>
</UserControl>