5

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?

Community
  • 1
  • 1
tnw
  • 13,521
  • 15
  • 70
  • 111
  • Is converting the text to a `Path` an option? or is it dynamic? – Chris W. Jul 24 '13 at 13:40
  • @ChrisW. Text is dynamic, yes. – tnw Jul 24 '13 at 13:42
  • 3
    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. Jul 24 '13 at 13:58

1 Answers1

9

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>
trinaldi
  • 2,872
  • 2
  • 32
  • 37