简体   繁体   中英

How do I get value from TimePicker(WPF) in C#?

I downloaded MaterialDesignTheme from nuget in visualstudio. http://materialdesigninxaml.net/

How do I get value form TimePicker? I want to make this value stored in the string buffer. How Can I implement MainWindow.xaml.cs?

<Grid Grid.Row="1" Grid.Column="1">
            <materialDesign:TimePicker
              Is24Hours="True"
              x:Name="PresetTimePicker"
              SelectedTimeChanged="PresetTimePicker_SelectedTimeChanged" Height="26" Margin="141,94,369,0" RenderTransformOrigin="-0.025,5.923" />
        </Grid>

The TimePicker control has a SelectedTime property that returns a DateTime? :

DateTime selectedTime = PresetTimePicker.SelectedTime.Value;
string formatted = selectedTime.ToString("HH:mm:ss");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM