根据背景更改TextBlock前景色 [英] Change TextBlock foreground color based on the background

查看:320
本文介绍了根据背景更改TextBlock前景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个简单的方法来改变 TextBlock 的前景颜色,基于它的背后的颜色,使它更可读。由于图片比文字更清晰,这里是我想要的:

I'm looking for a simple way to change the foreground color of a TextBlock based on the color of what is behind it, so that it is more readable. Since an image is more explicit than words, here's what I want:

我假设可以使用自定义着色效果,但我不知道如何创建它...无论如何,更简单的解决方案。

I assume it could be done with a custom shader effect, but I have no idea how to create it... Anyway, perhaps there is a simpler solution.

任何想法都是欢迎的!

推荐答案

上面是一个进度条,这里是一个很棒的解决方案:

Assuming the above is a progressbar, here is a great solution:

WPF progress bar with dynamic text&文字颜色更新

这篇关于根据背景更改TextBlock前景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆