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

Localization

1 Answer 78 Views
TimePicker
This is a migrated thread and some comments may be shown as answers.
JULIA
Top achievements
Rank 1
JULIA asked on 09 Sep 2010, 11:52 AM
Hi,

I'm using a RadTimePicker in a ControlTemplate and would like to set "DateTimeWatermarkContent" to another value. Unfortunately the value is not used and shows still "Enter time". Also I would like to change the Header on the drop down clock which has value "Clock".

Here the code:

<ContentControl Grid.Row="1" Grid.Column="1" Width="80" Style="{StaticResource styleContentControlTime}" Content="{Binding OfficeHour.MondayOpen, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" ></ContentControl>

here the style:

 <Style x:Key="styleContentControlTime" TargetType="ContentControl">
        <Setter Property="IsTabStop" Value="false"></Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding  Path=InEditMode}" Value="true">
                <Setter Property="ContentControl.Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <telerik:RadTimePicker SelectedValue="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContentControl}}, Path=Content, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                                                       Margin="10,3" DateTimeWatermarkContent="" >
                                </telerik:RadTimePicker>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </DataTrigger>

            <DataTrigger Binding="{Binding  Path=InEditMode}" Value="false">
                <Setter Property="ContentControl.Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Grid >
                                <TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContentControl}}, Path=Content, Converter={StaticResource dateTimeToTimeStringConverter}}"
                                           Style="{StaticResource styleTextBlock}" VerticalAlignment="Center"></TextBlock>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>

regrads,
Timo

1 Answer, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 13 Sep 2010, 01:55 PM
Hello Timo,

Find the code snippet bellow as a recommended approach to set a WatermarkContnet and custom clock header property(you need to expose the ClockStyle property of the picker control).

<Style x:Key="styleContentControlTime" TargetType="ContentControl">
    <Setter Property="IsTabStop" Value="false"></Setter>
    <Style.Triggers>
        <DataTrigger Binding="{Binding  Path=InEditMode}" Value="true">
            <Setter Property="ContentControl.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <telerik:RadDateTimePicker InputMode="TimePicker"
                                    SelectedValue="{Binding Content,RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                                    Margin="10,3"
                                    DateTimeWatermarkContent="test watermark content">
                                <telerik:RadDateTimePicker.ClockStyle>
                                    <Style TargetType="telerik:RadClock">
                                        <Setter Property="Header" Value="Some Custom Header" />
                                    </Style>
                                </telerik:RadDateTimePicker.ClockStyle>
                            </telerik:RadDateTimePicker>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </DataTrigger>
        <DataTrigger Binding="{Binding  Path=InEditMode}" Value="false">
            <Setter Property="ContentControl.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Grid>
                            <TextBlock
                                    Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContentControl}}, Path=Content, Converter={StaticResource dateTimeToTimeStringConverter}}"
                                    Style="{StaticResource styleTextBlock}"
                                    VerticalAlignment="Center"></TextBlock>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </DataTrigger>
    </Style.Triggers>
</Style>


Kind regards,
Kaloyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TimePicker
Asked by
JULIA
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or