Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6386195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:59:37+00:00 2026-05-25T02:59:37+00:00

I have a textbox that is programmatically added to a canvas at some point

  • 0

I have a textbox that is programmatically added to a canvas at some point and I want all of the text to have a dropshadoweffect, but I don’t want that effect applied to the borders of the textbox itself. How do I do this? Adding a dropshadoweffect to the textbox applies the effect to the borders of the box and “blurs” the text a little but that’s not what I want and I cannot find any properties on the textbox that let me add an effect to the text alone. Do I really have to restyle the textbox or make my own template to achieve this??

Mind you this is a textbox, not a textblock (in which case I would just have copy/pasted from here)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:59:38+00:00Added an answer on May 25, 2026 at 2:59 am

    Update: Found a better way, you can skip the Border part if you apply the Effect directly to the ScrollViewer that encapsulates the text in the Template.

    <TextBox Text="Shadow Text">
        <TextBox.Resources>
            <Style TargetType="ScrollViewer">
                <Setter Property="Effect">
                    <Setter.Value>
                        <DropShadowEffect ShadowDepth="4"
                                          Direction="330"
                                          Color="Black"
                                          Opacity="0.5"
                                          BlurRadius="4"/>
                    </Setter.Value>
                </Setter>
            </Style>
        </TextBox.Resources>
    </TextBox>
    

    Update 2: Missed the part of creating the TextBox in code. Here is the c# equivalent to the Xaml above

    Setter effectSetter = new Setter();
    effectSetter.Property = ScrollViewer.EffectProperty;
    effectSetter.Value = new DropShadowEffect
    {
        ShadowDepth = 4,
        Direction = 330,
        Color = Colors.Black,
        Opacity = 0.5,
        BlurRadius = 4
    };
    Style dropShadowScrollViewerStyle = new Style(typeof(ScrollViewer));
    dropShadowScrollViewerStyle.Setters.Add(effectSetter);
    
    TextBox dropShadowTextBox = new TextBox();
    dropShadowTextBox.Text = "Shadow Text";
    dropShadowTextBox.Foreground = Brushes.Teal;
    dropShadowTextBox.FontSize = 40;
    dropShadowTextBox.Margin = new Thickness(10);
    dropShadowTextBox.Resources.Add(typeof(ScrollViewer), dropShadowScrollViewerStyle);
    

    Good question, one idea is to make the Background and BorderBrush Transparent for the TextBox and place it in a Border

    <Border BorderThickness="1"
            BorderBrush="#FF7F9DB9"
            SnapsToDevicePixels="True"
            UseLayoutRounding="True"
            Margin="10">
        <TextBox Text="Shadow Text"
                 Foreground="Teal"
                 FontSize="40"
                 Background="Transparent"
                 BorderBrush="Transparent">
            <TextBox.Effect>
                <DropShadowEffect ShadowDepth="4"
                            Direction="330"
                            Color="Black"
                            Opacity="0.5"
                            BlurRadius="4"/>
            </TextBox.Effect>
        </TextBox>
    </Border>
    

    Here is a comparison with a “normal” TextBox

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form, and want to programmatically alter the help text that displays
I have a textbox that a user can type some text into. The area
I have a TextBox that is bound to a Text-property on an Entity-object. I'd
I have a textbox that I would like for only numbers. But if I
I have a TextBox that has the TextChanged event set declaratively. In some cases,
I've recently added the JQuery autocomplete plug in and have a textbox that autocompletes
I have an HTML textbox that contains some SQL code that I need executed.
I have a UserControl that incorporates a textbox. I want to set the keyboardfocus
I have a TextBox, in which I set the content programmatically : LegalTextBlock.Text =
I have a textbox that I want to the user to write something in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.