Coding4Fun是一款很受WP开发者喜爱的开源类库,对于开发者来说,Coding4Fun上手很简单。只要从CodePlex下载Coding4Fun工具包,下载完成后,解压文件到一个文件夹中,里面有4个dll文件,列表如下:

新建一个Windows Phone 7项目,然后右键“引用”添加dll引用:

ProgressOverlay 动画

添加dll引用之后,我们就可以开始了,当我的RSS正在下载的时候需要一个ProgressOverlay动画或者“Loading Screen”。

在你需要控件的任何页面中添加以下命名空间:

  1. xmlns:Controls="clr-namespace:Coding4Fun.Phone.Controls;
  2. assembly=Coding4Fun.Phone.Controls"
  1. <Controls:ProgressOverlay Name="progressOverlay" >
  2. <Controls:ProgressOverlay.Content>
  3. <TextBlock>Loading</TextBlock>
  4. </Controls:ProgressOverlay.Content>
  5. </Controls:ProgressOverlay>

现在有了一个非常漂亮的加载屏幕了,当然在ProgressOverlay里面如果你是用MVVM或其他类似模型你要添加Visibility属性,当数据加载完成后要去关闭它。

关于对话框

现在我需要一个界面漂亮且具备功能强大的关于对话框,例如:如果他们点击我的twitter 、个人主页、E-mail 来发送相应的任务。

只需要一下几行代码就行了:

  1. var p = new AboutPrompt();
  2. p.VersionNumber = "2.0";
  3. p.Show("Michael
  4. Crump", "@mbcrump",
  5. "michael@michaelcrump.net", @http://michaelcrump.net/);

一个漂亮简洁的“关于”对话框只要几行代码就可以实现了。

输入框

Coding4Fun还带有一个漂亮可爱的输入提示框从用户抓取信息。

 

实现的代码也非常简单:

  1. InputPrompt input = new
  2. InputPrompt();
  3. input.Completed += (s, e) =>
  4. {
  5. MessageBox.Show(e.Result.ToString());
  6. };
  7. input.Title = "InputBox";
  8. input.Message = "What
  9. does a \"Developer Large\" T-Shirt Mean? ";
  10. input.Show();

PhoneHelper类

我非常喜欢PhoneHelper类,因为它让你很容易从WMAppManifest.xml文件获取数据,例如:从WMAppManifest.xml获取当前应用程序的版本。

只需以下这句代码就可以了:

  1. PhoneHelper.GetAppAttribute("Version");

当然你需要添加以下这句命名空间的引用:

  1. using Coding4Fun.Phone.Controls.Data;

如果没有一个强大的转换器你可能不那么容易去展示一些cool的控件。BooleanToVisibility 转换器可以将Boolean类型转换成Visibility类型值。

如勾选CheckBox的时候显示一个TextBox时就是一个好例子。

 

代码如下:

  1. <phone:PhoneApplicationPage.Resources>
  2. <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
  3. </phone:PhoneApplicationPage.Resources>
  4. <CheckBox x:Name="checkBox"/>
  5. <TextBlock Text="Display Text" Visibility="{Binding ElementName=checkBox, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter} }"/>

RoundButton

Coding4Fun 工具包提供了RoundButton and RoundToggleButton 控件,RoundToggleButton是一个UI组件,源自CheckBox控件并且暴露了一些额外的依赖属性,正如它名字所说的。这是一种扩展圆形的切换按钮且有自动反向图像的支持。RoundButton控件是一个圆形的且提供自动反向图像支持的扩展按钮

在开始使用RoundButton 和 RoundToggleButton控件之前我们需要添加Coding4Fun.Phone.Controls.dll的引用

第一步:添加“C4F”的前缀声明,确保你的页面声明了“c4fToolkit” 的命名空间。

xmlns:c4f="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls"

<c4f:RoundButton/>

<c4f:RoundToggleButton/>

RoundToggleButton控件从CheckBox继承了所有的属性和事件,RoundButton 控件去Button控件中继承了所有的属性和事件

Content 属性

这个属性来来自父类用户设置 RoundToggleButton/RoundButton 的内容

ImageSource属性

ImageSource 是一个ImageSource类型的依赖属性,它用户设置或获取RoundToggleButton / RoundButton 控件的图片

Orientation属性

Orientation是一个Orientation类型的依赖属性,它用于设置或获取RoundToggleButton / RoundButton 控件的方向

Examples

下面的例子我将使用2个图标

注:图标会自动根据Light主题的变化而适当的变化

Example1:RoundButton 示例

这个例子演示了如何设置RoundButton控件常用属性,添加如下xaml 代码

<StackPanel Orientation="Horizontal">

<c4f:RoundButton FontSize="18" Content="OK" BorderBrush="CornflowerBlue" />

<c4f:RoundButton FontSize="48" Content="48" Background="CornflowerBlue" />

<c4f:RoundButton Foreground="CornflowerBlue" FontSize="36" Content="36"/>

<c4f:RoundButton ImageSource="Images/appbar.delete.rest.png" Content="Delete"/>

</StackPanel>

下面分别是在Dark and Light  themes中的结果

Example2: RoundButton Orientation and ImageSource 属性的使用

<c4f:RoundButton Orientation="Horizontal" ImageSource="Images/appbar.feature.search.rest.png" Content="horizontal text"/>

Example3. RoundToggleButton控件示例

这个例子演示了如何设置RoundToggleButton控件常用属性,添加如下xaml 代码

<StackPanel Orientation="Horizontal">

<c4f:RoundToggleButton FontSize="18" Content="ok" BorderBrush="CornflowerBlue" /> <c4f:RoundToggleButton FontSize="48" Content="48" Background="CornflowerBlue" /> <c4f:RoundToggleButton Foreground="CornflowerBlue" FontSize="36" Content="36" />

<c4f:RoundToggleButton ImageSource="Images/appbar.delete.rest.png" Content="DELETE"/>

</StackPanel>

Example4: RoundToggleButton  Orientation and ImageSource 属性的使用

<c4f:RoundToggleButton Orientation="Horizontal" ImageSource="Images/appbar.feature.search.rest.png" Content="horizontal text"/>

Example5: RoundButton and RoundToggleButton 控件的禁用

<c4f:RoundButton x:Name="btn" IsEnabled="False" Orientation="Horizontal" ImageSource="Images/appbar.delete.rest.png"

Content="disabled button" />

使用Coding4Fun工具包的更多相关文章

  1. Windows Phone 8初学者开发—第17部分:Coding4Fun工具包简介

    原文 Windows Phone 8初学者开发—第17部分:Coding4Fun工具包简介 第17部分:Coding4Fun工具包简介 原文地址:  http://channel9.msdn.com/ ...

  2. Windows Phone 8初学者开发—第21部分:永久保存Wav音频文件

    原文 Windows Phone 8初学者开发—第21部分:永久保存Wav音频文件 第21部分:永久保存Wav音频文件 原文地址:http://channel9.msdn.com/Series/Win ...

  3. Windows Phone 8初学者开发—第20部分:录制Wav音频文件

    原文 Windows Phone 8初学者开发—第20部分:录制Wav音频文件 原文地址:http://channel9.msdn.com/Series/Windows-Phone-8-Develop ...

  4. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  5. 【NLP】干货!Python NLTK结合stanford NLP工具包进行文本处理

    干货!详述Python NLTK下如何使用stanford NLP工具包 作者:白宁超 2016年11月6日19:28:43 摘要:NLTK是由宾夕法尼亚大学计算机和信息科学使用python语言实现的 ...

  6. Coding4Fun Toolkit支持本地化解决办法

    在项目中需要使用Coding4Fun Toolkit中的TimePicker控件, 1. 但是在中文系统下显示的却是英文: 2. 最后发现,需要在源代码中添加中文资源,并重新编译出包含中文语言的dll ...

  7. Werkzeug工具包学习-官方例子Shortly分析

    为了学习werkzeug的wsgi框架工具,今天真对官网的例子进行调试运行.涉及到了werkzeug工具包,jinja2前端模版,以及redis内存库,之后可以灵活定制自己主页.再次,作以记录. 首先 ...

  8. Win10 UWP 开发系列:使用多语言工具包让应用支持多语言

    之前我在一篇blog中写过如何使用多语言工具包,见http://www.cnblogs.com/yanxiaodi/p/3800767.html 在WinEcos社区也发布过一篇详细的文章介绍多语言工 ...

  9. Neo4j图数据库管理系统开发笔记之一:Neo4j Java 工具包

    1 应用开发概述 基于数据传输效率以及接口自定义等特殊性需求,我们暂时放弃使用Neo4j服务器版本,而是在Neo4j嵌入式版本的基础上进行一些封装性的开发.封装的重点,是解决Neo4j嵌入式版本Emb ...

随机推荐

  1. Oracle 数据库和监听器开机自启动两种实现方法

    数据库和监听器开机自启动   编辑oratab文件: 修改:orcl:/u01/app/oracle/product/11.2.0/db_1:N            orcl:/u01/app/or ...

  2. selenium用jquery改变元素属性

    一.jQuery 语法 jQuery 语法是通过选取 HTML 元素,并对选取的元素执行某些操作. 1.基础语法: $(selector).action() 选择符(selector)即," ...

  3. 【linux】监控磁盘情况并自动删除备份文件

    背景:我有一个备份目录/home/kzy/bakup,会每天备份一些信息.随着日子一天天的过去,这个文件夹越来越大,终于把磁盘撑满了..... 需求:当磁盘占有率超过80%时自动删除该文件夹下最老的3 ...

  4. github git 无法读取远程仓库或无权限

    解决方法:重新设置ssh密钥 ssh-keygen -t rsa -C "http://github.com"//输入命令后按提示输入id_rsa.pub的存储地址 和密钥密码 地 ...

  5. MySQL 5.6表空间传输

    在MySQL 5.6 Oracle引入了一个可移动表空间的特征(复制的表空间到另一个服务器)和Percona Server采用部分备份,这意味着你现在可以备份单个数据库或表:由于Percona Ser ...

  6. hdu 6118度度熊的交易计划(费用流)

    度度熊的交易计划 Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  7. Java编程的逻辑 (37) - 泛型 (下) - 细节和局限性

    本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...

  8. transform:rotate/旋转

    <!DOCTYPE html> <html> <head> <style> div { width:100px; height:75px; backgr ...

  9. Codeforces 336D Dima and Trap Graph 并查集

    Dima and Trap Graph 枚举区间的左端点, 然后那些左端点比枚举的左端点小的都按右端点排序然后并查集去check #include<bits/stdc++.h> #defi ...

  10. linux入门系列

    Linux基础入门 常用Linux命令 linux学习笔记-1.man_page linux学习笔记-2.常用命令 linux学习笔记-3.文件相关命令 linux学习笔记-4.系统命令 linux学 ...