热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

自定义BusyIndicator控件

1.style2.cspublicclassCustomBusyIndicator:Control{privateconststringPART_CancelButtonPART

1. style

2. cs

public class CustomBusyIndicator : Control
{
private const string PART_CancelButton = "PART_CancelButton";

private Button innerCancelButton;

public event RoutedEventHandler CancelClick;

static CustomBusyIndicator()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomBusyIndicator), new FrameworkPropertyMetadata(typeof(CustomBusyIndicator)));
}

#region BusyContent

public string BusyContent
{
get { return (string)GetValue(BusyContentProperty); }
set { SetValue(BusyContentProperty, value); }
}

public static readonly DependencyProperty BusyCOntentProperty=
DependencyProperty.Register("BusyContent",
typeof(string),
typeof(CustomBusyIndicator),
new PropertyMetadata(""));

#endregion

#region IsBusy

public bool IsBusy
{
get { return (bool)GetValue(IsBusyProperty); }
set { SetValue(IsBusyProperty, value); }
}

public static readonly DependencyProperty IsBusyProperty =
DependencyProperty.Register("IsBusy",
typeof(bool),
typeof(CustomBusyIndicator),
new PropertyMetadata(false));

#endregion

#region Content

public object Content
{
get { return (object)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}

public static readonly DependencyProperty COntentProperty=
DependencyProperty.Register("Content",
typeof(object),
typeof(CustomBusyIndicator),
new PropertyMetadata(null));

#endregion

#region ContentTemplate

public DataTemplate ContentTemplate
{
get { return (DataTemplate)GetValue(ContentTemplateProperty); }
set { SetValue(ContentTemplateProperty, value); }
}

public static readonly DependencyProperty COntentTemplateProperty=
DependencyProperty.Register("ContentTemplate",
typeof(DataTemplate),
typeof(CustomBusyIndicator),
new PropertyMetadata(null));

#endregion

public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if (innerCancelButton != null)
{
innerCancelButton.Click -= InnerCancelButton_Click;
}
innerCancelButton = this.GetTemplateChild(PART_CancelButton) as Button;
if (innerCancelButton != null)
{
innerCancelButton.Click += InnerCancelButton_Click;
}
}

private void InnerCancelButton_Click(object sender, RoutedEventArgs e)
{
if (this.IsBusy)
{
this.IsBusy = false;
}
if (this.CancelClick != null)
{
this.CancelClick(this, e);
}
}
}

自定义BusyIndicator控件


推荐阅读
  • SortalinkedlistinO(nlogn)timeusingconstantspacecomplexity.这道题属于人生中第一次对链表进行操作,首先,不同于C++中的st ... [详细]
  • C#的Type对象的简单应用
    通过Type对象可以获取类中所有的公有成员直接贴代码:classMyClass{privatestringname;privateintid;publicstringcity;pu ... [详细]
  • 我使用Laravel5时遇到问题.当我运行“phparitsanmigrate”时,我收到了这个错误***************************************A ... [详细]
  • rbac 4表 常规设计
    rbac4表常规设计设计模型:1、管理员表(users)Schema::create('users',function(Blueprint$table){$tabl ... [详细]
  • npmimportuse这里我记录一下,视频地址和封面地址均引用的是服务器端得,本地的视频和图片 ... [详细]
  • C#设计模式(8)——桥接模式(Bridge Pattern)
    原文地址:http:www.cnblogs.comzhilipBridgePattern.html原文作者:Learninghard原文出处:博客园一、引言 ... [详细]
  • CentOS7.2详细安装步骤(二)
    7)语言设置(可以在上一个主界面进行设置,这里不用再次设置)8)SECURITY设置(安全设置)选择default(默认的)策略就可以,通过进行选择,单击完成即可Default#默 ... [详细]
  • 大数据分析Python有哪些爬虫框架
    一、ScrapyScrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架。可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中。。用 ... [详细]
  • 接口自动化相关面试题
    你好,我是懂Java的测试最近辅导简历,有同学向我反馈,自学过接口自动化、没有落地接口自动化项目办?还有很多同学落地实践过自 ... [详细]
  • 开发笔记:Xunit测试使用个人小结
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了Xunit测试使用个人小结相关的知识,希望对你有一定的参考价值。因工作中用到xunit测试,故总结下用法,以供个人参考使 ... [详细]
  • phpstorm使用和配置技巧
    1.使用phpstorm的过程中,有时光标不小心变成了方块状,怎么修复回来呢?见下图,去掉“Useblockcare ... [详细]
  • 一、问题开发中遇到将其它数据库数据插入到mysql数据库表中一直会报类似如下错误:Incorrectstringvalue:\xE6\x88\x91forcolumn ... [详细]
  • 各个组件confspark-env.sh配置spark的环境变量confspark-default.conf配置spark应用默认的配置项和spark-env.sh有重合之处,可在 ... [详细]
  • IOSUITableView解析(一)
    UITableView的作用由于Iphone的大小有限,所以UITableView的作用是巨大的。比如QQ,微博等应用都用到了该控件。UITableVi ... [详细]
  • 配置OracleACFS集群文件系统
    配置OracleACFS集群文件系统               2012-07-1010:18:39标签:asmacfs版权声明:原创作品,谢绝转载!否则将追究法律责任。     ... [详细]
author-avatar
zhengfke
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有