我从visualstudio的nuget下载了MaterialDesignTheme。 http://materialdesigninxaml.net/
如何从TimePicker获得价值? 我想将此值存储在字符串缓冲区中。 如何实现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>
答案 0 :(得分:1)
TimePicker
控件具有一个SelectedTime
属性,该属性返回一个DateTime?
:
DateTime selectedTime = PresetTimePicker.SelectedTime.Value;
string formatted = selectedTime.ToString("HH:mm:ss");