is rectangular gradient possible RRS feed

  • Question

  • I am trying to create a background for text and would like a rectangular gradient is this possible and if so how?

    I plan to load the textbox at runtime and apply a different colour dependant on the value in the TextBox

    Monday, May 16, 2011 1:27 PM

All replies

  • you can make TextBox Background Color in the Style.

    <Style  TargetType="TextBox">

            <Setter Property="Foreground" Value="Black"/>

            <Setter Property="FontSize" Value="11"/>

            <Setter Property="Width" Value="90"/>

            <Setter Property="Height" Value="20"/>

            <Setter Property="HorizontalAlignment" Value="Center"/>

            <Setter Property="VerticalAlignment" Value="Center"/>

            <Setter Property="Template">


                    <ControlTemplate TargetType="TextBox">

                        <Border CornerRadius="3" x:Name="bg" BorderBrush="#FF6C6C6C" BorderThickness="1" Background="Red">

                            <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>



                            <Trigger Property="IsEnabled" Value="false">

                                <Setter Property="Background" TargetName="bg" Value="Black"/>

                                <Setter Property="Foreground" Value="Red"/>







    Wednesday, July 6, 2011 1:39 PM