博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
silverlight控件学习笔记一
阅读量:7022 次
发布时间:2019-06-28

本文共 6343 字,大约阅读时间需要 21 分钟。

 

Calendar.xaml

 

 cs

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 Silverlight20.Control {
public partial class Calendar : UserControl {
public Calendar() {
InitializeComponent(); } private void calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e) {
// Calendar.SelectedDate - 选中的日期 // Calendar.SelectedDates - 选中的多个日期集合 this.txtMsg.Text = ""; foreach (DateTime dt in calendar.SelectedDates) {
this.txtMsg.Text += dt.ToString("yyyy-MM-dd"); this.txtMsg.Text += " "; } } private void CheckBox_Checked(object sender, RoutedEventArgs e) {
if (this.calendar.SelectedDate != null && this.calendar.SelectedDate < DateTime.Now.Date) this.calendar.SelectedDate = DateTime.Now; // Calendar.BlackoutDates - 不允许选择的日期集合 // Calendar.BlackoutDates.AddDatesInPast() - 禁止选择今天之前的日期 this.calendar.BlackoutDates.AddDatesInPast(); } private void CheckBox_Unchecked(object sender, RoutedEventArgs e) {
// Calendar.BlackoutDates.Clear() - 清除 不允许选择的日期集合 的设置 this.calendar.BlackoutDates.Clear(); } private void selectionMode_Changed(object sender, RoutedEventArgs e) {
// CalendarSelectionMode.None - 禁止选择日期 // CalendarSelectionMode.SingleRange - 可以选择多个日期,连续日期(Shift键配合) // CalendarSelectionMode.MultipleRange - 可以选择多个日期,任意日期(Ctrl键配合) // CalendarSelectionMode.SingleDate - 只能选择一个日期 switch (((System.Windows.Controls.RadioButton)sender).Name) {
case "None": this.calendar.SelectionMode = CalendarSelectionMode.None; break; case "SingleRange": this.calendar.SelectionMode = CalendarSelectionMode.SingleRange; break; case "MultipleRange": this.calendar.SelectionMode = CalendarSelectionMode.MultipleRange; break; default: this.calendar.SelectionMode = CalendarSelectionMode.SingleDate; break; } } } }

 

 

Image.xaml

 

Image.xaml.cs

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; using System.Windows.Media.Imaging; using System.Windows.Resources; namespace Silverlight20.Control {
public partial class Image : UserControl {
public Image() {
InitializeComponent(); // 后台方式设置Image的Source img.Source = new BitmapImage(new Uri("/Silverlight20;component/Images/Logo.jpg", UriKind.Relative)); StreamResourceInfo sri = Application.GetResourceStream( new Uri("/Silverlight20;component/Images/Logo.jpg", UriKind.Relative)); BitmapImage imageSource = new BitmapImage(); imageSource.SetSource(sri.Stream); img2.Source = imageSource; } } }

 

ProgressBar.Xaml

 

 

ProgressBar.cs

using System; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Threading; namespace SilverlightApplication50 {
public partial class progressBar : UserControl {
Storyboard loop = new Storyboard(); int count = 0; public progressBar() {
// 为初始化变量所必需 InitializeComponent(); initBar();//方法一 //initBar2();//方法二 } //利用定时器每隔一段时间执行 private void initBar() {
//使用DispatcherTimer之前,要引用using System.Windows.Threading;命名空间 DispatcherTimer timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0,0,1); timer.Tick += new EventHandler(timer_Tick); timer.Start(); } //利用动画的时间间隔 private void initBar2() {
loop.Duration = TimeSpan.FromMilliseconds(10d); loop.Completed += new EventHandler(loop_Completed); loop.Begin(); } void timer_Tick(object sender, EventArgs e) {
bar2.Value = count; if (count > 100) {
count = 0; } else {
count++; } } void loop_Completed(object sender, EventArgs e) {
bar2.Value = count; if (count>100) {
count = 0; } else {
count++; } loop.Begin(); } } }

 

 

Slider.xaml

 

 

Slider.xaml.cs

 

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 Silverlight20.Control {
public partial class Slider : UserControl {
public Slider() {
InitializeComponent(); } private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs
e) {
// RoutedPropertyChangedEventArgs
.OldValue - Slider控件的原值 // RoutedPropertyChangedEventArgs
.NewValue - Slider控件的新值 lblMsg.Text = string.Format("原值:{0}\r\n新值:{1}", e.OldValue.ToString(), e.NewValue.ToString()); } } }

 

TabControl.xaml

 

 

摘自:

 

 

 

转载于:https://www.cnblogs.com/eagle1986/archive/2011/09/22/2184843.html

你可能感兴趣的文章
织云Lite发布:详解包管理核心能力
查看>>
hadoop04---shell
查看>>
HDU 4419 Colourful Rectangle(线段树)
查看>>
webservice接口的开发和调用
查看>>
【uTenux实验】内存池管理(固定内存池和可变内存池)
查看>>
Android——Android Studio的一些小技巧(转)
查看>>
Spring学习【Spring概述】
查看>>
【Java数据结构学习笔记之一】线性表的存储结构及其代码实现
查看>>
Facebook内部人才建设潜规则
查看>>
巧用test判断来写shell脚本
查看>>
类装载器
查看>>
考勤处理脚本
查看>>
原生的社交分享
查看>>
[leetcode]Valid Sudoku
查看>>
静态成员和实例成员
查看>>
IIS的负载均衡的解决方案
查看>>
有效加快Windows 7运行速度
查看>>
磁盘清理无法删除DUMP文件手工删
查看>>
Java线程:创建与启动
查看>>
.Net开发笔记(八) 动态编译
查看>>