How to put hours in control Datepicker WPF C #?

1

I need you to choose the day and time but I think it is not compatible with the hours or can you change the format?

<DatePicker x:Name="dpFirst" HorizontalAlignment="Left" Margin="430,29,0,0" VerticalAlignment="Top" DisplayDate="2018-06-18" SelectedDateFormat="Short"/>
    
asked by Luis Acosta 18.06.2018 в 21:47
source

1 answer

1

You can look at the extension DateTimePicker

I've tried not to use the extension and I get to see the time, but I can not select it so it always puts you at 00:00. I leave the code in case it can help you:

<DatePicker x:Name="dpFirst" HorizontalAlignment="Left" Margin="5,29,0,0" VerticalAlignment="Top" DisplayDate="2018-06-18"  SelectedDateFormat="Short" Width="181">
        <DatePicker.Resources>
        <Style TargetType="{x:Type DatePickerTextBox}">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <TextBox x:Name="PART_TextBox"
                                 Text="{Binding Path=SelectedDate, StringFormat='yyyy-MM-dd HH:mm', 
 RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
            </DatePicker.Resources>
    </DatePicker>

Greetings

    
answered by 19.06.2018 / 08:36
source