Alex Zhukovskiy
Alex Zhukovskiy

Reputation: 10055

How to select date and time in WPF

i'm looking for a control, that allow select both date and time. Default DatePicker doesn't allow it. But custom controls (like Extended WPFToolkit) are expensive, anothers are not free...

Upvotes: 3

Views: 3460

Answers (1)

Alex Zhukovskiy
Alex Zhukovskiy

Reputation: 10055

At the moment I posted it I came to a solution. So I leave it here if someone needs it:

    <DatePicker Name="Picker">
        <DatePicker.Resources>
            <Style TargetType="DatePickerTextBox">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <TextBox Text="{Binding Path=SelectedDate, RelativeSource={RelativeSource AncestorType=DatePicker}, StringFormat={}{0:dd/MM/yyyy hh:mm:ss}}"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </DatePicker.Resources>
    </DatePicker>

Upvotes: 4

Related Questions