如何将 dropshadoweffect 添加到文本框的文本(以编程方式)
我有一个在某个时刻以编程方式添加到画布的文本框,我希望所有文本都具有投影效果,但我不希望将该效果应用于文本框本身的边框。我该怎么做?向文本框添加 dropshadoweffect 会将效果应用到框的边框并稍微“模糊”文本,但这不是我想要的,并且我在文本框中找不到任何可让我单独向文本添加效果的属性。我真的必须重新设计文本框或制作自己的模板才能实现此目的吗?
请注意,这是一个文本框,而不是文本块(在这种情况下,我只需从 此处)
I have a textbox that is programmatically added to a canvas at some point and I want all of the text to have a dropshadoweffect, but I don't want that effect applied to the borders of the textbox itself. How do I do this? Adding a dropshadoweffect to the textbox applies the effect to the borders of the box and "blurs" the text a little but that's not what I want and I cannot find any properties on the textbox that let me add an effect to the text alone. Do I really have to restyle the textbox or make my own template to achieve this??
Mind you this is a textbox, not a textblock (in which case I would just have copy/pasted from here)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新:找到了更好的方法,如果将
Effect
直接应用于ScrollViewer
,则可以跳过Border
部分将文本封装在模板中。更新2:错过了在代码中创建
TextBox
的部分。这是与上面的 Xaml 等效的 C#好问题,一个想法是使
TextBox
的背景和 BorderBrush 透明,并将其放置在Border
中,这是与一个“正常”
TextBox
Update: Found a better way, you can skip the
Border
part if you apply theEffect
directly to theScrollViewer
that encapsulates the text in the Template.Update 2: Missed the part of creating the
TextBox
in code. Here is the c# equivalent to the Xaml aboveGood question, one idea is to make the Background and BorderBrush Transparent for the
TextBox
and place it in aBorder
Here is a comparison with a "normal"
TextBox