I'm trying to add an effect to style in order to reuse it, but from some reason it doesnt work...
<Style x:Key="NumericTextBoxStyle" TargetType="{x:Type TextBox}">
<Style.Resources>
<TextBox.Effect x:Key="EffectStyle">
<DropShadowEffect BlurRadius="56"
Direction="392"
Color="#FF872E2E"
RenderingBias="Quality"/>
</TextBox.Effect>
</Style.Resources>
<Setter Property="Height" Value="25"/>
<Setter Property="Width" Value="120"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="TextAlignment" Value="Center"/>
</Style>
but how do i add the style part ? (also how do i declare for the effect ?)
thanks
Select the shape or text box. On the Drawing Tools Format tab, click Text Fill > More Fill Colors. In the Colors box, either click the color you want on the Standard tab, or mix your own color on the Custom tab. Custom colors and colors on the Standard tab aren't updated if you later change the document theme.
On the Format tab, in the Shape Styles group, click Shape Effects, and select an option from the list. To add or change a built-in combination of effects, point to Preset, and then click the effect that you want. To customize the built-in effect, click 3-D Options, and then choose the options that you want.
Try to add the Effect as a Setter instead
<Style x:Key="NumericTextBoxStyle" TargetType="{x:Type TextBox}">
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="56"
Direction="392"
Color="#FF872E2E"
RenderingBias="Quality"/>
</Setter.Value>
</Setter>
<Setter Property="Height" Value="25"/>
<Setter Property="Width" Value="120"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="TextAlignment" Value="Center"/>
</Style>
Or if you want to have the Effect as a Resource in the Style you can do it like this
<Style x:Key="NumericTextBoxStyle" TargetType="{x:Type TextBox}">
<Style.Resources>
<DropShadowEffect x:Key="dropShadowEffect"
BlurRadius="56"
Direction="392"
Color="#FF872E2E"
RenderingBias="Quality"/>
</Style.Resources>
<Setter Property="Effect" Value="{StaticResource dropShadowEffect}"/>
<!--...-->
</Style>
You can also make your effect a global resource, in order to use it with other styles/controls:
<Grid>
<Grid.Resources>
<DropShadowEffect x:Key="dropShadowEffect" BlurRadius="56"
Direction="392"
Color="#FF872E2E"
RenderingBias="Quality"/>
<Style x:Key="NumericTextBoxStyle" TargetType="{x:Type TextBox}">
<Setter Property="Effect" Value="{StaticResource dropShadowEffect}" />
<Setter Property="Height" Value="25"/>
<Setter Property="Width" Value="120"/>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBox Style="{StaticResource NumericTextBoxStyle}" />
<TextBox Style="{StaticResource NumericTextBoxStyle}" Grid.Row="1" />
<ComboBox Effect="{StaticResource dropShadowEffect}" Grid.Row="2" />
</Grid>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With