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. appium-Could not obtain screenshot: [object Object]

    原因 App页面已经被禁止截屏,禁用用户截屏的代码如下: getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); setConten ...

  2. mysql 字符编码设置

    安装mysql时如果字符编码为默认值latin1,则需要修改为utf8以便支持中文数据. 命令如下: 1.显示数据库字符集 mysql> show create database test;+- ...

  3. sublime sftp 打开远程文件夹

    2014-04-29 13:19:09 总结: 本文介绍两种方法,推荐第二种方法(samba+windows映射) 先贴出sublime打开远程(Linux)目录所需的配置文件(sublime是通过s ...

  4. Android网络框架之Retrofit + RxJava + OkHttp 变化的时代

    1.什么是Retrofit框架? 它是Square公司开发的现在非常流行的网络框架,所以我们在导入它的包的时候都可以看到这个公司的名字,目前的版本是2. 特点: 性能好,处理快,使用简单,Retrof ...

  5. 解决创建maven项目Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart问题

    今天用eclipse创建项目的时候报错如下图: 解决方案: 1.下载最新版maven-archetype-quickstart-1.1.jar   2.命令行到下载目录下执行mvn install:i ...

  6. day25作业

    1.阻塞  2.就绪  3.阻塞  4.Runnable  5.join()  6.synchronized  7.notify()和notifyAll()   8.Object 1.A   2.D  ...

  7. CMT跟踪算法学习笔记(一)

    关于这个算法,已经有网友写出笔记. 这位网友用画图的方式总结出了算法的各个流程,并总结了源码中的各个类:http://blog.csdn.net/roamer_nuptgczx/article/det ...

  8. 2011TG初赛

    一.单项选择题(共20题,每题1.5分,共计30分,每题有且仅有一个正确选项.) 1. 在二进制下,1011001+( )=1100110. A.1011 B.1101 C.1010 D.1111 B ...

  9. Codeforces 671A Recycling Bottles(贪心+思维)

    题目链接:http://codeforces.com/problemset/problem/671/A 题目大意:给你两个人的位置和一个箱子的位置,然后给出n个瓶子的位置,要求让至少一个人去捡瓶子放到 ...

  10. QT5 - 数据库、QMYSQL driver not loaded

    第一步.先在“.pro”的入口文件里加入以下两行代码: QT += sql SOURCES += main.cpp 第二步.在“main.cpp”文件中连接数据库并判断是否连接成功 1.QPSQL连接 ...