是否有可能在Windows Phone 8中勾勒出文字,例如我有红色文字,但我希望大纲是黑色的?
我应该在C#的xaml中执行此操作,如果可能的话,该怎么做?任何例子都将非常感激
感谢名单
答案 0 :(得分:2)
在这里你可以看到它是如何完成的:http://blog.mrlacey.co.uk/2010/06/silverlight-effects-and-windows-phone-7.html
它不再起作用了。由于性能问题,Microsoft删除了它。
应用程序使用这些效果所带来的性能损失给系统带来了太大的压力,并且决定如果我们无法提供性能功能,我们将禁用,直到我们可以这样做。
唯一的可能是创建2个TextBlock并更改FontSize,RenderTransfor,FontWeight,...
<TextBlock Text="{Binding ElementName=BackgroundText,Path=Text}" FontSize="25" Foreground="Red" FontWeight="ExtraBold">
</TextBlock>
<TextBlock Text="Hello" Name="BackgroundText" FontSize="25" Foreground="White" FontWeight="Bold">
<TextBlock.RenderTransform>
<TranslateTransform X="0.5" Y="0" />
</TextBlock.RenderTransform>
</TextBlock>
</TextBlock>
答案 1 :(得分:1)
由于两个具有不同FontWieghts的TextBlocks无法帮助您处理大文本(仅比简单的“Hello”更长),因为较大的文本将比较薄文本提前,我建议您使用4个TextBlocks向左移动1,右上角等设置Opacity = 0.5以使轮廓平滑。 这是一个例子:
<TextBlock Grid.Row="0" Text="Outlined text" Style="{StaticResource OutlineTb}">
<TextBlock.RenderTransform>
<TranslateTransform X="-1" Y="1" />
</TextBlock.RenderTransform>
</TextBlock>
<TextBlock Grid.Row="0" Text="Outlined text" Style="{StaticResource OutlineTb}">
<TextBlock.RenderTransform>
<TranslateTransform X="-1" Y="-1" />
</TextBlock.RenderTransform>
</TextBlock>
<TextBlock Grid.Row="0" Text="Outlined text" Style="{StaticResource OutlineTb}">
<TextBlock.RenderTransform>
<TranslateTransform X="1" Y="-1" />
</TextBlock.RenderTransform>
</TextBlock>
<TextBlock Grid.Row="0" Text="Outlined text" Style="{StaticResource OutlineTb}">
<TextBlock.RenderTransform>
<TranslateTransform X="1" Y="1" />
</TextBlock.RenderTransform>
</TextBlock>
<TextBlock Grid.Row="0"
Text="Outlined text"
FontSize="25"
Foreground="White"
FontWeight="Normal">
</TextBlock>
风格:
<Style TargetType="TextBlock" x:Key="OutlineTb">
<Setter Property="FontSize" Value="25" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Opacity" Value="0.5" />
</Style>
但请记住,这是一个非常“沉重”的解决方案,仍然不如真正的大纲。