Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Update:</strong> Found a better way, you can skip the <code>Border</code> part if you apply the <code>Effect</code> directly to the <code>ScrollViewer</code> that encapsulates the text in the Template.</p> <pre class="lang-xml prettyprint-override"><code>&lt;TextBox Text="Shadow Text"&gt; &lt;TextBox.Resources&gt; &lt;Style TargetType="ScrollViewer"&gt; &lt;Setter Property="Effect"&gt; &lt;Setter.Value&gt; &lt;DropShadowEffect ShadowDepth="4" Direction="330" Color="Black" Opacity="0.5" BlurRadius="4"/&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/TextBox.Resources&gt; &lt;/TextBox&gt; </code></pre> <p><strong>Update 2:</strong> Missed the part of creating the <code>TextBox</code> in code. Here is the c# equivalent to the Xaml above</p> <pre><code>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); </code></pre> <hr> <p>Good question, one idea is to make the Background and BorderBrush Transparent for the <code>TextBox</code> and place it in a <code>Border</code></p> <pre class="lang-xml prettyprint-override"><code>&lt;Border BorderThickness="1" BorderBrush="#FF7F9DB9" SnapsToDevicePixels="True" UseLayoutRounding="True" Margin="10"&gt; &lt;TextBox Text="Shadow Text" Foreground="Teal" FontSize="40" Background="Transparent" BorderBrush="Transparent"&gt; &lt;TextBox.Effect&gt; &lt;DropShadowEffect ShadowDepth="4" Direction="330" Color="Black" Opacity="0.5" BlurRadius="4"/&gt; &lt;/TextBox.Effect&gt; &lt;/TextBox&gt; &lt;/Border&gt; </code></pre> <p>Here is a comparison with a "normal" <code>TextBox</code></p> <p><img src="https://i.stack.imgur.com/l7LY5.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload