5
votes

I have a Silverlight app where I want to give my textblock an outline (not the textblock, the characters themselves), otherwise known as stroke.

I found this question which works for WPF, but is there a way to accomplish this when working with XAML/Silverlight (PresentationFramework is not a Silverlight assembly)? Is there an existing implementation?

1
Is converting the text to a Path an option? or is it dynamic?Chris W.
@ChrisW. Text is dynamic, yes.tnw
Only way I could think of doing this reasonably easily without a lot of code behind is build a quick ContentControl that applies a couple DropShadowEffect outlines in different directions to its ContentPresenter and just load your text through it to get the same effect.Chris W.

1 Answers

8
votes

Going with @Chris W. idea, I came up with this code, although not the finest solution, it works:

<StackPanel>

    <!-- With DropShadow -->
    <TextBlock Foreground="#FFFF0000" Text="With DropShadow" FontSize="16">
        <TextBlock.Effect>
            <DropShadowEffect ShadowDepth="0" BlurRadius="1" Color="#FF000000" />
        </TextBlock.Effect>
    </TextBlock>

     <!-- No DropShadow -->
    <TextBlock Foreground="#FFFF0000" Text="No DropShadow" FontSize="16" />

</StackPanel>