Wpf 工具包中的 TimePicker

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15447963/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 08:07:01  来源:igfitidea点击:

TimePicker in Wpf Toolkit

wpfxamlwpftoolkittimepicker

提问by muhammedkasva

I want a timepicker control in WPF. I found an implementation here.(http://wpftoolkit.codeplex.com/wikipage?title=TimePicker&referringTitle=Home). I have installed it. But couldn't understand how to use it. I don't know what I need to write in the XAML file.

我想要一个 WPF 中的时间选择器控件。我在这里找到了一个实现。(http://wpftoolkit.codeplex.com/wikipage?title=TimePicker&referringTitle=Home)。我已经安装了它。但无法理解如何使用它。我不知道我需要在 XAML 文件中写什么。

回答by Rohit Vats

Instructions are provided in the link itself here. Follow these steps and you are good to go -

此处的链接本身提供了说明。按照以下步骤操作,您就可以开始了 -

  1. Install the binaries first from here.

  2. Extract the dll Xceed.Wpf.Toolkitand add reference to this dll in your project.

  3. In XAMLadd the namespace - xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"

  1. 首先从这里安装二进制文件。

  2. 提取 dllXceed.Wpf.Toolkit并在您的项目中添加对此 dll 的引用。

  3. XAML添加命名空间 -xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"

4.Then add the instance of TimePickerControlin your xaml -

4.然后TimePickerControl在你的xaml中添加实例-

<Grid>
   <xctk:TimePicker Height="30" Width="100" Value="{Binding CurrentDateTime}"/>
</Grid>

In your ViewModel -

在您的 ViewModel -

private DateTime currentDateTime = DateTime.Now;
public DateTime CurrentDateTime
{
   get
   {
      return currentDateTime ;
   }
   set
   {
      currentDateTime = value;
   }
}