04 2012 档案

摘要:说明:该案例与前一个案例的来源一样,同样讲述的是MVVM,算是MVVM的进阶吧。在该案例中,涉及到数据访问,Prism等更为复杂的问题。首先来看界面设计,我在作者的基础上稍微做了改动,大致如下:1.首先还是来一个解决方案的截图:2.实现步骤2.1)从OO的角度来说,首先是完成基类的书写,该案例主要有两个对象,是Dish类(菜品类)和Restaurant(餐馆类),实现起来都较为简单,具体如下:Restaurant Class 1 public class Restaurant 2 { 3 /// <summary> 4 /// 餐馆名称 5 ... 阅读全文
posted @ 2012-04-10 11:32 January 阅读(2565) 评论(1) 推荐(0)
摘要:说明:关于什么是MVVM,园子中已经有很多文章做过介绍,自己对MVVM也有了初步的认识,算是一知半解吧。概念看起来总是有那么点抽象,简单的办法就是通过动手实践来进一步理解。从网上弄了几个案例,相信有人看过,在此只为了自己加深对MVVM的认识。1.目录结构,MVVM的目录结构大致如下:2.类图及实现过程简单的实现过程大致如下,首先就是手动实现两个接口:INotifyPropertyChanged,ICommand.2.1 INotifyPropertyChanged 接口的实现 1 //1.继承INotifyPropertyChanged,要引用该命名空间 2 using System.Comp 阅读全文
posted @ 2012-04-09 17:23 January 阅读(1375) 评论(0) 推荐(0)
摘要:说明:通过本例对BackgroundWorker的WorkerReportsProgress,WorkerSupportsCancdllation属性及Dowork,ProessChanged,RunWorkerCompleted事件做进一步的了解。 1 public partial class Form1 : Form 2 { 3 public Form1() 4 { 5 InitializeComponent(); 6 7 //获取或设置一个值,该值指示BW报告能否报告进度更新 8 ... 阅读全文
posted @ 2012-04-09 11:58 January 阅读(830) 评论(0) 推荐(0)
摘要:1 //错误的处理 2 private void cmdBreakRules_Click(object sender, RoutedEventArgs e) 3 { 4 Thread thread = new Thread(UpdateTextWrong); 5 thread.Start(); 6 } 7 8 private void UpdateTextWrong() 9 {10 txt.Text = "Here is some ... 阅读全文
posted @ 2012-04-09 11:35 January 阅读(1461) 评论(1) 推荐(0)
摘要:说明:希望通过揣摩这些案例,能进一步了解进程的工作原理。1.方法一描述的是在同一窗口中,在计算素数的同时而不影响Canvas的工作。方法1 1 #region Long-Running Calculation in UI Thread 2 3 public delegate void NextPrimeDelegate(); 4 private long num = 3; 5 private bool continueCalculating = false; 6 private bool fNotAPrime =... 阅读全文
posted @ 2012-04-09 10:33 January 阅读(1907) 评论(0) 推荐(0)
摘要:说明:在数据绑定时,如果有些字段为空值,那么在数据绑定时可以用默认值来显示为空的字段。 1 <Grid> 2 <ListBox x:Name="lstPeople" Width="400"> 3 <ListBox.ItemTemplate> 4 <DataTemplate> 5 <StackPanel Orientation="Horizontal"> 6 <TextBlock Text="{Binding Path=FirstNam... 阅读全文
posted @ 2012-04-06 17:22 January 阅读(5131) 评论(1) 推荐(0)
摘要:1 2 <Window x:Class="MainWindow" 3 Loaded="Window_Loaded"> 4 5 <ListBox x:Name="lstPeople" Width="200"> 6 <ListBox.ItemTemplate> 7 <DataTemplate> 8 <StackPanel> 9 <StackPanel Orientation="Horizontal">10 ... 阅读全文
posted @ 2012-04-06 17:09 January 阅读(2264) 评论(0) 推荐(0)
摘要:<Window.Resources> <DrawingImage x:Key="OverlayImageVector"> <DrawingImage.Drawing> <GeometryDrawing Brush="Red"> <GeometryDrawing.Geometry> <RectangleGeometry Rect="0 0 16 16" RadiusX="3" RadiusY="3" /> ... 阅读全文
posted @ 2012-04-06 16:56 January 阅读(2901) 评论(1) 推荐(1)
摘要:1 <Window.TaskbarItemInfo> 2 <TaskbarItemInfo /> 3 </Window.TaskbarItemInfo> 4 5 <Grid> 6 <ProgressBar x:Name="ProgressBar" Margin="10" 7 HorizontalAlignment="Stretch" 8 VerticalAlignment="Center" 9 Height... 阅读全文
posted @ 2012-04-06 16:32 January 阅读(2161) 评论(0) 推荐(0)
摘要:1 namespace Easing2 2 { 3 4 5 //EasingFunctionBase 为所有缓动函数提供基类 6 class CustomPowerEase : EasingFunctionBase 7 { 8 9 // Using a DependencyProperty as the backing store for Power.10 // This enables animation, styling, binding, etc...11 12 // UIPropertyMetadata(object Defa... 阅读全文
posted @ 2012-04-06 15:30 January 阅读(1035) 评论(0) 推荐(0)
摘要:1 <Grid> 2 3 <Rectangle Stroke="Olive" Width="300" Height="300" > 4 5 <Rectangle.Fill> 6 <!--StattPoint,二维起始坐标,默认为(0,0)--> 7 <LinearGradientBrush StartPoint="0,0" EndPoint="0.012,0.012" SpreadMethod="Reflect"> 阅读全文
posted @ 2012-04-06 12:54 January 阅读(1508) 评论(0) 推荐(0)
摘要:说明:本例简单展示了InkCanvas的使用,并详细列出了InkCanvasEditingMode的枚举值。 <Grid> <InkCanvas Name="inkCanvas" Background="Ivory"> <InkCanvas.DefaultDrawingAttributes> <Ink:DrawingAttributes xmlns:ink="system-windows-ink" Color="Red" Width="5" /> 阅读全文
posted @ 2012-04-06 10:57 January 阅读(1954) 评论(0) 推荐(0)
摘要:Thumb类,表示可由用户拖动的控件。其主要三个事件分别DragDelta,DragStarted,DragCompleted.DragDelta——当Thumb控件具有逻辑焦点和鼠标捕获时,随着鼠标位置更改发生一次或多次。DragStarted——在Thumb控件接收逻辑焦点和鼠标捕获时发生。DragCompleted——在Thumb控件失去鼠标捕获时发生。 1 <Window.Resources> 2 <ResourceDictionary> 3 <ControlTemplate x:Key="template1"> 4 <El 阅读全文
posted @ 2012-04-06 10:43 January 阅读(6334) 评论(0) 推荐(0)
摘要:1 <Window x:Class="ClipToBounds.Window1" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 Title="ClipToBounds" Height="300" Width="300" 5 > 6 <!--ClipToB 阅读全文
posted @ 2012-04-06 10:09 January 阅读(2136) 评论(1) 推荐(1)
摘要:案例实现效果:通过鼠标左键单击窗口空白处,按住鼠标来拖动窗口。该案例实现很简单,可以应用在一些自定义窗口(如窗口不显示标题栏等情况)。<Window x:Class="ClickWhitespaceAndDrag.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="ClickWhitespaceAnd 阅读全文
posted @ 2012-04-05 17:40 January 阅读(277) 评论(0) 推荐(0)