• 大小: 154KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-04
  • 语言: C#
  • 标签: datetime  picker  wpf  c#  .net  

资源简介

wpf没有datetimepicker控件,网上虽然有很多资源,但是都有这样那样的bug或不如意,比如上下左右键不管用,数字键不管用等,滚轮调整不管用等,于是以一个老外写的控件为蓝本,自己改了一个,应该是目前最好的了,实现了全部常用的交互方式

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Markup;
using System.Windows;
using System.Windows.Media;
using System.ComponentModel;

namespace Loya.Dameer
{
    public enum DateTimePickerFormat { Long Short Time Custom }

    [System.ComponentModel.DefaultBindingProperty(“Value“)]

    public class Dameer : Control
    {
        private CheckBox _checkBox;
        internal TextBox _textBox;
        private TextBlock _textBlock;
        private Popup _popUp;
        private Calendar _calendar;
        private BlockManager _blockManager;
        private string _defaultFormat = “MM/dd/yyyy hh:mm:ss tt“;
        [Category(“Dameer“)]
        public bool ShowCheckBox
        {
            get { return this._checkBox.Visibility == System.Windows.Visibility.Visible ? true : false; }
            set
            {
                if (value)
                    this._checkBox.Visibility = System.Windows.Visibility.Visible;
                else
                {
                    this._checkBox.Visibility = System.Windows.Visibility.Collapsed;
                    this.Checked = true;
                }
            }
        }
        [Category(“Dameer“)]
        public bool ShowDropDown
        {
            get { return this._textBlock.Visibility == System.Windows.Visibility.Visible ? true : false; }
            set
            {
                if (value)
                    this._textBlock.Visibility = System.Windows.Visibility.Visible;
                else
                    this._textBlock.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
        [Category(“Dameer“)]
        public bool Checked
        {
            get { return this._checkBox.IsChecked.HasValue ? this._checkBox.IsChecked.Value : false; }
            set { this._checkBox.IsChecked = value; }
        }
        [Category(“Dameer“)]
        private string FormatString
        {
            get
            {
                switch (this.Format)
                {
                    case DateTimePickerFormat.Long:
                        return “dddd MMMM dd yyyy“;
                    case DateTimePickerFormat.Short:
                        return “M/d/yyyy“;
                    case DateTimePickerFormat.Time:
                        return “h:mm:ss tt“;
                    case DateTimePickerFormat.Custom:
                        if (string.IsNullOrEmpty(this.CustomFormat))
                            return this._defaultFormat;
                        else
                            return this.CustomFormat;
                    default:
                        return this._defaultFormat;
                }
            }
        }
        private string _customFormat;
        [Category(“Dameer“)]
        public string 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1125  2010-06-23 11:59  Loya.Dameer\Help.txt

     文件      20992  2012-12-28 17:05  Loya.Dameer\Loya.Dameer\bin\Debug\Loya.Dameer.dll

     文件      44544  2012-12-28 17:05  Loya.Dameer\Loya.Dameer\bin\Debug\Loya.Dameer.pdb

     文件      20582  2012-12-28 17:05  Loya.Dameer\Loya.Dameer\Dameer.cs

     文件       3664  2012-12-28 10:53  Loya.Dameer\Loya.Dameer\Loya.Dameer.csproj

     文件       6228  2012-12-28 17:05  Loya.Dameer\Loya.Dameer\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       2903  2010-06-22 11:42  Loya.Dameer\Loya.Dameer\obj\Debug\GeneratedInternalTypeHelper.g.i.cs

     文件        214  2010-06-22 12:03  Loya.Dameer\Loya.Dameer\obj\Debug\GenerateResource.read.1.tlog

     文件        478  2010-06-22 12:03  Loya.Dameer\Loya.Dameer\obj\Debug\GenerateResource.write.1.tlog

     文件       1442  2012-12-28 10:40  Loya.Dameer\Loya.Dameer\obj\Debug\Loya.Dameer.csproj.FileListAbsolute.txt

     文件        917  2012-12-28 10:40  Loya.Dameer\Loya.Dameer\obj\Debug\Loya.Dameer.csproj.GenerateResource.Cache

     文件      20992  2012-12-28 17:05  Loya.Dameer\Loya.Dameer\obj\Debug\Loya.Dameer.dll

     文件      44544  2012-12-28 17:05  Loya.Dameer\Loya.Dameer\obj\Debug\Loya.Dameer.pdb

     文件        180  2012-12-28 10:53  Loya.Dameer\Loya.Dameer\obj\Debug\Loya.Dameer.Properties.Resources.resources

     文件        244  2010-06-22 11:42  Loya.Dameer\Loya.Dameer\obj\Debug\Loya.Dameer_MarkupCompile.i.cache

     文件        231  2010-06-22 11:42  Loya.Dameer\Loya.Dameer\obj\Debug\Loya.Dameer_MarkupCompile.i.lref

     文件     202233  2010-06-23 11:46  Loya.Dameer\Loya.Dameer\obj\Debug\ResolveAssemblyReference.cache

     文件       4608  2012-12-28 10:53  Loya.Dameer\Loya.Dameer\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件       2286  2010-06-22 11:41  Loya.Dameer\Loya.Dameer\Properties\AssemblyInfo.cs

     文件       2862  2012-12-28 10:53  Loya.Dameer\Loya.Dameer\Properties\Resources.Designer.cs

     文件       5612  2010-06-22 11:41  Loya.Dameer\Loya.Dameer\Properties\Resources.resx

     文件       1111  2012-12-28 10:53  Loya.Dameer\Loya.Dameer\Properties\Settings.Designer.cs

     文件        201  2010-06-22 11:41  Loya.Dameer\Loya.Dameer\Properties\Settings.settings

     文件       2551  2010-06-22 11:59  Loya.Dameer\Loya.Dameer.sln

    ..A..H.     40448  2012-12-28 17:07  Loya.Dameer\Loya.Dameer.suo

     文件        144  2012-12-28 10:53  Loya.Dameer\Sample\app.config

     文件        316  2010-06-22 16:50  Loya.Dameer\Sample\App.xaml

     文件        308  2010-06-22 11:57  Loya.Dameer\Sample\App.xaml.cs

     文件      20992  2012-12-28 17:05  Loya.Dameer\Sample\bin\Debug\Loya.Dameer.dll

     文件      44544  2012-12-28 17:05  Loya.Dameer\Sample\bin\Debug\Loya.Dameer.pdb

............此处省略55个文件信息

评论

共有 条评论