Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
307 views
in Technique[技术] by (71.8m points)

c# - Apply stroke to textblock in XAML

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...