使高光画笔与控制画笔相同,而不指定颜色
我想确保选定的 ListViewItem 的非焦点背景与焦点背景相同。我知道这样做的常见方法如下:
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Blue"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Blue"/>
但是,问题是我不想指定一种颜色,我只想让键为 ControlBrushKey 的静态资源返回的 Brush 与其相同对于HighlightBrushKey。
I want to ensure that a selected ListViewItem's non-focused background is the same as the focused background. I know that the common way of doing this is as follows:
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Blue"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Blue"/>
However, the problem is that I don't want to specify a colour, I merely want the Brush returned by the static resource whose key is ControlBrushKey to be the same as the one for HighlightBrushKey.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案是这样的:
The answer is this:
试试这个...我知道它可以设置两个属性来匹配,不确定它是否适用于您的上下文,但值得一试:
我使用 TextBox 作为游乐场进行了测试。我不确定您的确切应用程序,但这是我的测试标记:
这只是将背景设置为蓝色,将前景设置为背景,这是预期的结果。
Try this... I know it works to set two properties to match, not sure if it will work in your context, but it's worth a shot:
I tested this using a TextBox as a playground. I'm not sure of your exact application, but here was my test markup:
This just set the background to blue, and the foreground to the background, which was the expected result.