This is a migrated thread and some comments may be shown as answers.

Background of disabled DatePicker

3 Answers 143 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 02 Jul 2012, 04:19 PM
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

3 Answers, 1 is accepted

Sort by
0
Masha
Telerik team
answered on 03 Jul 2012, 08:17 AM
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 >>
0
Tom
Top achievements
Rank 1
answered on 03 Jul 2012, 10:53 AM
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

 

0
Tom
Top achievements
Rank 1
answered on 03 Jul 2012, 01:54 PM

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
Tags
DatePicker
Asked by
Tom
Top achievements
Rank 1
Answers by
Masha
Telerik team
Tom
Top achievements
Rank 1
Share this question
or