WPF:是否存在输入格式“MM:SS”的时间设置控制的示例。 (QUOT; 59:59")?

问题描述:

我们的WPF应用程序需要一个时间设置控件,它只允许输入为"MM:SS"。 MM和SS的格式和有效范围是0-59。

Our WPF application needs a Time Setup control which only allow input as "MM:SS" format and valid range for MM and SS is 0-59.

是否有一个很好的自定义WPF控件实例来实现这一目标? Thx!  

Is there a good example of custom WPF control to achieve this goal? Thx!  

JaneC

嗨JJChen,

Hi JJChen,

我建议您可以使用两个组合框控件来限制输入。像这样:

I would suggest that you could use two combobox control to restrict input. like this:

<WrapPanel> <ComboBox SelectedValue="{Binding dateTime.Min}" SelectedValuePath="Content"> <ComboBoxItem>00</ComboBoxItem> <ComboBoxItem>01</ComboBoxItem> ...

< ComboBoxItem> 59< / ComboBoxItem>
< / ComboBox>
< TextBlock Text =":" />
< ComboBox SelectedValue =" {Binding dateTime.Sec}" SelectedValuePath = QUOT;内容和QUOT;&GT;
< ComboBoxItem> 00< / ComboBoxItem>
...

<ComboBoxItem>59</ComboBoxItem> </ComboBox> <TextBlock Text=":"/> <ComboBox SelectedValue="{Binding dateTime.Sec}" SelectedValuePath="Content"> <ComboBoxItem>00</ComboBoxItem> ...

< ComboBoxItem> 59< / ComboBoxItem>
< / ComboBox>
< / WrapPanel>

<ComboBoxItem>59</ComboBoxItem> </ComboBox> </WrapPanel>

祝你好运,

张龙