Background of disabled DatePicker

4 posts, 0 answers
  1. Tom
    Tom avatar
    3 posts
    Member since:
    Jul 2012

    Posted 02 Jul 2012 Link to this post

    Hey Guys,

    Can you give me a hand and tell me how to change Background Color of TextBox of disabled DatePicker? I attached the screenshot.

    Regards,
    Tom
  2. Masha
    Admin
    Masha avatar
    355 posts

    Posted 03 Jul 2012 Link to this post

    Hi Tom,

    You can change the Background color of RadWatermarkTextBox in a disabled RadDateTimePicker by
    creating an implicit style for RadWatermarkTextBox. There you can find the disable state visual, which you need to customize.

    Inside the control template of RadWatermarkTextBox, find the following:
    <Border x:Name="DisabledVisualElement" BorderBrush="#FF989898" BorderThickness="{TemplateBinding BorderThickness}" Background="#FFE0E0E0"
                                        CornerRadius="1" IsHitTestVisible="False" Opacity="0"/>

    Changing the Background of this border, will change the Background of RadWatermarkTextBox when disabled.

    I hope this will be helpful.

    Regards,
    Maria
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Tom
    Tom avatar
    3 posts
    Member since:
    Jul 2012

    Posted 03 Jul 2012 Link to this post

    Hi,

    Thanks for the reply. I'm much closer, but not there yet. Can you provide me with more extended example? I did this:

    <Style TargetType="telerik2:RadWatermarkTextBox">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik2:RadWatermarkTextBox">
                    <Border x:Name="DisabledVisualElement" BorderBrush="#FF989898" BorderThickness="{TemplateBinding BorderThickness}" Background="#FFE0E0E0"
                                    CornerRadius="1" IsHitTestVisible="False" Opacity="0">
                        <TextBlock Text="{Binding Path=SelectedDate, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadDatePicker}}}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


     

    But that solution overrides DisplayFormat.
    Is there a way to change only Background without interfering with the rest of ControlTemplate?
    If not, can you provide me with the original ControlTemplate so I could just change things I nedd to change and leave the rest?

    Regards,
    Tom

     

  5. Tom
    Tom avatar
    3 posts
    Member since:
    Jul 2012

    Posted 03 Jul 2012 Link to this post

    Allright,
    So I did this:

    <Style TargetType="telerik:RadDatePicker">
        <Setter Property="Background" Value="Green" />
    </Style>
      
    <Style TargetType="telerik2:RadWatermarkTextBox">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik2:RadWatermarkTextBox">
                    <ContentPresenter Content="{Binding Path=CurrentDateTimeText, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadDatePicker}}}" /            
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    And it worked for me (except some styling which has to be done additionally).
    Case closed.

    Regards,
    Tomasz
Back to Top