禁用 TextBlock 上的不透明蒙版
我正在尝试为 WP7 创建自定义删除线(因为它不支持 SL4/WPF 删除线)。
我通过创建一个 2px 高的矩形并将其放置在距底部 33% 的位置(作为 Segeo WP 字体删除线的默认值)来完成此操作。
然而,对于看起来像不透明蒙版的东西来说,这是一个相当奇怪的问题。
删除线是对文本块进行一些屏蔽,这是有意为之的。所以我正在寻找有关如何解决此问题的任何想法。
XAML 的片段:
<TextBlock x:Name="ContentContainer"
Text="{TemplateBinding Content}"
Grid.Column="0"
Foreground="{TemplateBinding Foreground}"
HorizontalAlignment="Left"
Margin="0,0,0,0"
OpacityMask="{x:Null}"
Padding="{TemplateBinding Padding}"
FontSize="{StaticResource PhoneFontSizeLarge}" />
<Rectangle x:Name="CheckBorder"
Fill="{StaticResource PhoneDisabledBrush}"
Margin="0,26,0,15"
OpacityMask="{x:Null}"
Width="{Binding Width, ElementName=ContentContainer}"
Height="2"/>
如您所见,我尝试将 OpacityMask 设置为 {x:Null},但可惜的是,这根本没有效果。
I'm attempting to create a custom strikethrough line for WP7 (since it doesn't support the SL4/WPF strikethough).
I've done this by creating a 2px high rectangle, and placing it 33% from the bottom (as default for the Segeo WP font strikethrough).
However, this a rather strange issue with something that looks like a opacity mask.
The strikethrough is doing some masking on the textblock, and this is very much intendedly. So I'm looking for any ideas on how I can fix this.
Snippet of the XAML:
<TextBlock x:Name="ContentContainer"
Text="{TemplateBinding Content}"
Grid.Column="0"
Foreground="{TemplateBinding Foreground}"
HorizontalAlignment="Left"
Margin="0,0,0,0"
OpacityMask="{x:Null}"
Padding="{TemplateBinding Padding}"
FontSize="{StaticResource PhoneFontSizeLarge}" />
<Rectangle x:Name="CheckBorder"
Fill="{StaticResource PhoneDisabledBrush}"
Margin="0,26,0,15"
OpacityMask="{x:Null}"
Width="{Binding Width, ElementName=ContentContainer}"
Height="2"/>
As you can see I've tried setting the OpacityMask to {x:Null}, but alas, this have no effect at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是一个 OpacityMask 问题 - 相反,我认为这是两组
PhoneDisabledColor
画笔组合在一起。从资源来看,
PhoneDisabledColor
的不透明度为 40% 白色,因此,当您将两个具有此不透明度的对象放在彼此之上时,您会得到您所看到的绘图效果 - 部分的透明度大于 40 % 不透明度。
这里列出了删除线的解决方案 - http://forums.silverlight.net/forums /t/19749.aspx
编辑/更新 - 查看该解决方案后,我认为它可能会显示您所见过的相同问题。
通过 Windows Phone 7 中的删除线文本找到
I'm not sure this is an OpacityMask problem - instead I think it's two sets of
PhoneDisabledColor
brushes combining together.From the resources, it looks like
PhoneDisabledColor
is 40% opacity whiteSo when you place two objects with this opacity on top of each other then you get the drawing effect you've seen - sections with stronger than 40% opacity.
There is a solution for strikethrough listed here - http://forums.silverlight.net/forums/t/19749.aspx
Edit/Update - having looked at that solution, I think it might show the same problem you have seen.
Found via Strikeout text in Windows phone 7