Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select date and time in WPF

Tags:

c#

datetime

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...

like image 226
Alex Zhukovskiy Avatar asked Jan 28 '26 03:01

Alex Zhukovskiy


1 Answers

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>
like image 145
Alex Zhukovskiy Avatar answered Jan 29 '26 16:01

Alex Zhukovskiy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!