2019-8-30-win10-uwp-好看的时间选择控件

title author date CreateTime categories
win10 uwp 好看的时间选择控件
lindexi
2019-08-30 08:57:20 +0800
2018-06-15 20:57:43 +0800
Win10 UWP

本文告诉大家我找到的好看的时间选择控件。

先给大家看一下图,然后就知道我说的是什么

首先需要安装 Nuget ,搜索 DeanChalk.UWP.TimePicker 或输入Install-Package DeanChalk.UWP.TimePicker -Version 1.0.0 安装必要的库

几乎所有在 xaml 引用其他大佬的库都需要先添加引用,这里需要添加的引用请看下面代码

    xmlns:deanChalk="using:DeanChalk.UWP.TimePicker"

在加上引用之后要使用这个新的控件是非常简单,只需要下面一句代码

         <deanChalk:TimePicker x:Name="TimePicker" BorderThickness="0"></deanChalk:TimePicker>

这时可以把 TimePicker 的 Time 和原生的 TimePicker 绑定,当然现在绑定了时间控件还不能运行

         <TimePicker Margin="10,10,10,10" HorizontalAlignment="Center" Time="{x:Bind TimePicker.Time,Mode=TwoWay}"></TimePicker>

如果要运行代码,那么请复制我的代码

     <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
         <deanChalk:TimePicker x:Name="TimePicker" BorderThickness="0"></deanChalk:TimePicker>
         <TimePicker Margin="10,10,10,10" HorizontalAlignment="Center" Time="{x:Bind TimePicker.Time,Mode=TwoWay}"></TimePicker>
         <TextBlock >
             如果你觉得我这个应用好用,那么请点击下面的按钮退出
             <LineBreak></LineBreak>
             如果觉得我这个应用不好用,那么继续用吧
         </TextBlock>
         <Button Margin="10,10,10,10" HorizontalAlignment="Center" Content="确定" Click="SasjuRasdrasgebi_OnClick"></Button>
        </StackPanel>

上面的代码是不需要后台代码,大家只要把代码复制在 MainPage.xaml 文件运行就可以看到上面的图片

这里点击按钮退出软件请看 How to use code to exit the application in UWP

原文地址:https://www.cnblogs.com/lindexi/p/12085995.html