【发布时间】:2017-09-08 06:04:12
【问题描述】:
由于某种原因,没有简单的方法可以将 TextBox 的焦点背景从默认的白色更改。
它的唯一工作方式(我需要它是暗色或透明的)是创建自定义文本框,粘贴无数行代码(来自here),然后编辑两行:
<VisualState x:Name="Focused">
<Storyboard>
...
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="#000000" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement" Soryboard.TargetProperty="Opacity">
<DiscreteObjectKeyFrame KeyTime="0" Value="0.1" />
</ObjectAnimationUsingKeyFrames>
我的问题是:有更好的方法吗?是否需要所有其他代码(约 240 行)? 谢谢。
【问题讨论】:
-
我想你可以使用behaviors。从未与他们合作过,但他们应该让这种定制变得更容易。