DatePicker的BlackoutDates,日历控件可选范围设定。
来源:互联网 发布:中银淘宝卡申请 编辑:程序博客网 时间:2024/05/18 03:16
简述:
在已存在的时间列表中,存在以下条件
1、当日及以上的时间可选。
2、已存在的时间可选的范围是存在的时间的第二天,到下个月的1日。
画面代码:
<UserControl x:Class="SilverlightApplication2.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400" > <Grid x:Name="LayoutRoot" Background="White"> <sdk:DatePicker Height="23" HorizontalAlignment="Left" Margin="61,83,0,0" Name="datePicker1" VerticalAlignment="Top" Width="120" /> </Grid></UserControl>
后台代码:
using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;namespace SilverlightApplication2{ public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); InitDatePicker(); } private void InitDatePicker() { List<DateTime> list = this.GetDateTime(); List<DateTime> hanTime = new List<DateTime>(); for (int i = 0; i < list.Count - 1; i++) { DateTime d1 = list[i]; DateTime d2 = list[i + 1]; if (i == 0) { this.datePicker1.BlackoutDates.Add(new CalendarDateRange(new DateTime(), d1)); } this.datePicker1.BlackoutDates.Add(new CalendarDateRange(d1)); DateTime dt = new DateTime(d1.Year, d1.AddMonths(1).Month, 1); if (d1.Month != d2.Month && dt != d2) { List<DateTime> hanTimeList = this.GetTimeList(d1, d2); this.datePicker1.BlackoutDates.Add(new CalendarDateRange(hanTimeList[0], hanTimeList[1])); } } this.datePicker1.BlackoutDates.Add(new CalendarDateRange(list[list.Count - 1])); }
//已存在时间列表 private List<DateTime> GetDateTime() { List<DateTime> rtn = new List<DateTime>(); DateTime time = new DateTime(2014, 8, 12); DateTime time3 = new DateTime(2014, 8, 15); DateTime time1 = new DateTime(2014, 9, 27); DateTime time2 = new DateTime(2014, 9, 28); DateTime time4 = new DateTime(2014, 9, 30); DateTime time7 = new DateTime(2014, 10, 1); DateTime time5 = new DateTime(2014, 10, 12); DateTime time6 = new DateTime(2014, 12, 1); rtn.Add(time); rtn.Add(time3); rtn.Add(time1); rtn.Add(time2); rtn.Add(time4); rtn.Add(time7); rtn.Add(time5); rtn.Add(time6); return rtn; }
//上一个时间和下一个时间移除范围
private List<DateTime> GetTimeList(DateTime d1, DateTime d2) { List<DateTime> hanTime = new List<DateTime>(); DateTime dt = d1.AddMonths(1); hanTime.Add(new DateTime(dt.Year, dt.Month, 2)); hanTime.Add(d2.AddDays(-1)); return hanTime; } }}
0 0
- DatePicker的BlackoutDates,日历控件可选范围设定。
- JQuery 日历控件Datepicker的简单使用
- jquery 日历控件 datepicker的使用
- bootstrap-datepicker日历控件的使用心得
- Swing Datepicker(日历控件)
- 日历控件之DatePicker
- bootstrap-datepicker限定可选时间范围
- bootstrap-datepicker限定可选时间范围
- 可选年月的日历
- 日历控件my97 datepicker-1
- 设置日期控件可选范围
- My97 DatePicker——强大的 JavaScript 日历控件
- Jquery UI的日历控件datepicker限制日期
- My97 DatePicker一款好用的日历控件
- Jquery UI的日历控件datepicker限制日期
- jquery日历datepicker的使用方法
- My97 Datepicker 日历控件 $dp拒绝访问
- 开源日历控件DatePicker源码解析
- Spring:ModelAndView addObject
- Android Looper和Handler
- PHP通过table标签实现输出EXCEL的方法
- Spring的核心机制:依赖注入
- Linux 动态库剖析
- DatePicker的BlackoutDates,日历控件可选范围设定。
- 最大流算法--Ford-Fulkerson方法及其多种实现
- 安卓手机数据损坏了怎么修复
- 百度竞价批量查询排名-度哥软件
- 人工智能之坑:理想化是巨头通病
- 用按键精灵2014最新版功能怎么开发脚本
- RS485自行收发的实现方法
- 代码中设置dip大小
- ALV排序统计功能