我试图在焦点时更改我的输入框上的颜色。WPF文本框在焦点上更改颜色
首先我声明输入按钮:
<TextBox x:Name="usernameTextBox"
HorizontalAlignment="Left"
Height="23"
Margin="115,31,0,0"
TextWrapping="Wrap"
VerticalAlignment="Top"
Width="277"
GotFocus="usernameTextBox_GotFocus"/>
而且下面我尝试添加的风格为文本框
<Style x:Key="usernameTextBox"
TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="IsFocused"
Value="true">
<Setter Property="Background"
Value="{StaticResource OnMouseOverColor}" />
</Trigger>
</Style.Triggers>
</Style>
错误:
Error 1 A value of type 'Style' cannot be added to a collection or dictionary of type 'UIElementCollection'. D:\VS\VIM\VIM_WPF\login.xaml 15 9 VIM_Wpf
任何其他解决办法如何解决这一问题?
什么不管用? – Phiter
检查新更新 – Ivan