XAML(eXtensible Application Markup Language,可扩展应用程序标记语言)是一种声明式的编程语言,遵循XML的语法。WPF使用XAML来设计UI具有易用性、高效性等特点。易用性主要表现在设计师在不需懂逻辑代码的情况下就可以使用Expression Blend设计出优雅的界面以及一些动画效果。我们将分两个大的部分来说明,一个是XAML基本认识,另一个是XAML中最重要的X命名空间。

1.XAML基本认识

下面我们新建一个WPF应用程序,看看Xaml页面有哪些基本的东西

从上图我们可以看出Xaml有一个根元素Window,根元素下有一个子元素Grid,表示出清晰的层级关系。Window还有一些属性(Attribute):

x:Class属于x命名空间的内容,我们后面详述

xmlns是XML Namespace的缩写,等号后面看起来像一个URL,其实是采用硬编码(Hard Code)的形式来引用一些.net命名空间。

如果要引用多个命名空间,为了区别,我们可以用标识前缀来限定修饰,如xmlns:x

Tilte、Height、Width属性用来修饰Window

1.1集合语法

<Window x:Class="XamlDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Ellipse Width="80" Height="80">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.5,0.5">
<RadialGradientBrush.GradientStops>
<GradientStop Offset="0" Color="Red" />
<GradientStop Offset="0.6" Color="Green" />
<GradientStop Offset="1" Color="Blue" />
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
</Grid>
</Window>

RadialGradientBrush.GradientStops是一个GradientStop集合,我们可以像上面那样来编写

1.2Xaml内容属性

XAML 指定了一个语言功能,通过该功能,一个类可以指定它的一个且仅一个属性为 XAML 内容属性。 该对象元素的子元素用于设置该内容属性的值。 换言之,仅对内容属性而言,您可以在 XAML 标记中设置该属性时省略属性元素,并在标记中生成更直观的父级/子级形式。本文刚开始给了一张图片,在Window下放了一个Grid,其实它的完整写法应该是这样:

<Window x:Class="XamlDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Content>
<Grid> </Grid>
</Window.Content>
</Window>

由上面代码知道,Content属性是Window的默认内容属性,因此你可以直接省略它,这样看起来更直观。

1.3文本内容

有少量 XAML 元素可直接将文本作为其内容来处理。 若要实现此功能,必须满足以下条件之一:

1.类必须声明一个内容属性,并且该内容属性必须是可赋值给字符串的类型(该类型可以是 Object)。

2. 类型必须声明一个类型转换器,该类型转换器将文本内容用作其初始化文本。 例如,<Brush>Blue</Brush>。 这种情况实际上并不常见。

3.类型必须为已知的 XAML 语言基元。

我们来举个例子看看:

<Window x:Class="XamlDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="5" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Ellipse Width="80" Height="80">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.5,0.5">
<RadialGradientBrush.GradientStops>
<GradientStop Offset="0" Color="Red" />
<GradientStop Offset="0.6" Color="Green" />
<GradientStop Offset="1" Color="Blue" />
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Button Grid.Column="2">
Button
<Button.Background>
Red
</Button.Background>
</Button>
</Grid>
</Window.Content>
</Window>

上面代码中Button有一个Content内容属性(可省略书写),其类型为Object,满足第一条;

Background属性是Brush类型,它是一个抽象类,系统内置有其子类SolidColorBrush类型转化器,故将会把Red文本(对应的#FF0000这种RGB文本值也可以)转换为SolidColorBrush类型,满足第二条,所以可以写成上面那样。

1.4自定义TypeConverter

上面我们知道,WPF内置许多的TypeConverter,使得我们在使用Xaml时能够随心所欲。下面我们也得实现一个TypeConverter:

首先创建一个Person类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XamlDemo;
using System.ComponentModel; namespace XamlDemo
{
[TypeConverter(typeof(StringToPersonTypeConverter))]
public class Person
{
public string Name { get; set; }
public Person Child { get; set; }
}
}

然后创建一个继承自TypeConverter的StringToPersonTypeConverter,重写里面的ConvertFrom方法:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel; namespace XamlDemo
{
class StringToPersonTypeConverter:TypeConverter
{
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value is string)
{
Person p = new Person();
p.Name = value.ToString();
return p;
}
return base.ConvertFrom(context, culture, value);
}
}
}

然后在Xaml中使用:

<Window x:Class="XamlDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:XamlDemo"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="20" />
</Style>
<XmlDataProvider x:Key="xdp1" XPath="Students/Student">
<x:XData>
<Students xmlns="">
<Student Name="Jello"/>
<Student Name="Taffy"/>
</Students>
</x:XData>
</XmlDataProvider>
<local:Person x:Key="person1" Child="Jello" />
</Window.Resources>
<Window.Content>
<StackPanel x:Name="stackpanel1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="5" />
<RowDefinition Height="100" />
<RowDefinition Height="5" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Ellipse Width="80" Height="80">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.5,0.5">
<RadialGradientBrush.GradientStops>
<GradientStop Offset="0" Color="Red" />
<GradientStop Offset="0.6" Color="Green" />
<GradientStop Offset="1" Color="Blue" />
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Button Grid.Column="2">
Button
<Button.Background>
#FF0000
</Button.Background>
</Button>
<TextBlock x:Name="txtblock1" Grid.Row="2" Text="Hello" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Name="txtblock2" Grid.Row="2" Grid.Column="2" Text="Hello" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="{Binding Path=Text,ElementName=myTextBlock1}" Background="{x:Static Member=SystemColors.GrayTextBrush}" Style="{x:Null}" Grid.Row="4" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<ListBox Grid.Column="2" Grid.Row="4" ItemsSource="{Binding Source={StaticResource xdp1}}" DisplayMemberPath="@Name"/>
</Grid>
<local:MyTextBlock Text="Hello" x:Name="myTextBlock1"/>
<local:MyTextBlock Text="Hello"/>
</StackPanel>
</Window.Content>
</Window>

后台代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes; namespace XamlDemo
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.txtblock1.Text = "World";
this.txtblock2.Text = "World"; //有x:Name修饰的MyTextBlock
this.myTextBlock1.Text = "World";
MessageBox.Show(this.myTextBlock1.Text); //无x:Name修饰的MyTextBlock
MyTextBlock myTextBlock = this.stackpanel1.Children[] as MyTextBlock;
if (myTextBlock != null)
{
myTextBlock.Text = "World";
MessageBox.Show(myTextBlock.Text);
} //自定义TypeConverter
Person p = this.FindResource("person1") as Person;
if (p != null)
{
MessageBox.Show(p.Child.Name);
}
}
}
}

这样,我们简单实现了一个TypeConverter。

2.x命名空间

由上面我们知道,xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"这个就是x命名空间,命名成x不是必须得,当然也可以命名成xmlns:y="http://schemas.microsoft.com/winfx/2006/xaml",这里只是约定而已(命名为x代表这是Xaml相关的命名空间)。我们来下里面都有些什么:

有上图可以看出x命名空间中主要有Attribute、标记扩展和指令元素三种。下面我们将分别看下具体使用:

2.1Attribute

我们拿最常使用的x:Name来看下:

Xaml代码:

<Window x:Class="XamlDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="5" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Ellipse Width="80" Height="80">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.5,0.5">
<RadialGradientBrush.GradientStops>
<GradientStop Offset="0" Color="Red" />
<GradientStop Offset="0.6" Color="Green" />
<GradientStop Offset="1" Color="Blue" />
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Button Grid.Column="2">
Button
<Button.Background>
#FF0000
</Button.Background>
</Button>
<TextBlock x:Name="txtblock1" Grid.Row="2" Text="Hello" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Name="txtblock2" Grid.Row="2" Grid.Column="2" Text="Hello" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Window.Content>
</Window>

后台代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes; namespace XamlDemo
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.txtblock1.Text = "World";
this.txtblock2.Text = "World";
}
}
}

运行发现两个TextBlock的文本显示都变成了World,那我们不经要问x:Name和Name有什么区别呢?我们知道TextBlock的Name属性是从FrameworkElement类中继承的,用于引用标签对应的实例,和ASPX中重的ID作用差不多,当一个标签或者自定义元素不是继承自FrameworkElement时,就无法获取它的Name属性了,这将导致在后台中访问该标签变得麻烦。我们举个例子来看下:

首先我们自定义一个继承自UIElement的MyTextBlock类,只有一个Text属性。

然后我们在Xaml中引用它,需要在根元素中加入xmlns:local="clr-namespace:XamlDemo",代码如下:

Xaml代码:

<Window x:Class="XamlDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:XamlDemo"
Title="MainWindow" Height="350" Width="525">
<Window.Content>
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="5" />
<RowDefinition Height="100" />
<RowDefinition Height="5" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Ellipse Width="80" Height="80">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.5,0.5">
<RadialGradientBrush.GradientStops>
<GradientStop Offset="0" Color="Red" />
<GradientStop Offset="0.6" Color="Green" />
<GradientStop Offset="1" Color="Blue" />
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Button Grid.Column="2">
Button
<Button.Background>
#FF0000
</Button.Background>
</Button>
<TextBlock x:Name="txtblock1" Grid.Row="2" Text="Hello" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Name="txtblock2" Grid.Row="2" Grid.Column="2" Text="Hello" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<local:MyTextBlock Text="Hello" x:Name="myTextBlock1"/>
<local:MyTextBlock Text="Hello"/>
</StackPanel>
</Window.Content>
</Window>

后台代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes; namespace XamlDemo
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.txtblock1.Text = "World";
this.txtblock2.Text = "World"; //有x:Name修饰的MyTextBlock
this.myTextBlock1.Text = "World";
MessageBox.Show(this.myTextBlock1.Text); //无x:Name修饰的MyTextBlock
MyTextBlock myTextBlock = this.stackpanel1.Children[] as MyTextBlock;
if (myTextBlock != null)
{
myTextBlock.Text = "World";
MessageBox.Show(myTextBlock.Text);
}
}
}
}

其实,x:Name的作用有两个:一是为标签生成对应的实例并可以用x:Name的值引用它;二是如果这个标签继承自FrameworkElement类,那么也让其Name属性来引用生成的实例。

2.2标记扩展

Xaml标记扩展对应System.Window.Markup.MarkupExtension抽象类,查看它的子类,点击这里

举个例子来说明它的用法:

<Window x:Class="XamlDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:XamlDemo"
Title="MainWindow" Height="350" Width="525">
<Window.Content>
<StackPanel x:Name="stackpanel1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="5" />
<RowDefinition Height="100" />
<RowDefinition Height="5" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Ellipse Width="80" Height="80">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.5,0.5">
<RadialGradientBrush.GradientStops>
<GradientStop Offset="0" Color="Red" />
<GradientStop Offset="0.6" Color="Green" />
<GradientStop Offset="1" Color="Blue" />
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Button Grid.Column="2">
Button
<Button.Background>
#FF0000
</Button.Background>
</Button>
<TextBlock x:Name="txtblock1" Grid.Row="2" Text="Hello" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Name="txtblock2" Grid.Row="2" Grid.Column="2" Text="Hello" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="{Binding Path=Text,ElementName=myTextBlock1}" Grid.Row="4" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<local:MyTextBlock Text="Hello" x:Name="myTextBlock1"/>
<local:MyTextBlock Text="Hello"/>
</StackPanel>
</Window.Content>
</Window>

上面代码只是多加了一个TextBlock,看起来奇怪的是它的Text、Background和Style属性的值,是用一对大括号来包括的,这就是我们要说的标记扩展。

构造语法:{标记扩展类 [可选参数]},可选参数包括命名参数和定位参数。

标记扩展类:x:Null、x:Static和Binding;

命名参数:Binding中的Path和Element;

定位参数:x:Static中Member

这里还有一个{}转义序列的问题,请点击这里

2.3指令元素

主要就两个x:XData和x:Code,这里举个x:XData例子:

<Window x:Class="XamlDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:XamlDemo"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="20" />
</Style>
<XmlDataProvider x:Key="xdp1" XPath="Students/Student">
<x:XData>
<Students xmlns="">
<Student Name="Jello"/>
<Student Name="Taffy"/>
</Students>
</x:XData>
</XmlDataProvider>
</Window.Resources>
<Window.Content>
<StackPanel x:Name="stackpanel1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="5" />
<RowDefinition Height="100" />
<RowDefinition Height="5" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Ellipse Width="80" Height="80">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.5,0.5">
<RadialGradientBrush.GradientStops>
<GradientStop Offset="0" Color="Red" />
<GradientStop Offset="0.6" Color="Green" />
<GradientStop Offset="1" Color="Blue" />
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Button Grid.Column="2">
Button
<Button.Background>
#FF0000
</Button.Background>
</Button>
<TextBlock x:Name="txtblock1" Grid.Row="2" Text="Hello" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Name="txtblock2" Grid.Row="2" Grid.Column="2" Text="Hello" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="{Binding Path=Text,ElementName=myTextBlock1}" Background="{x:Static Member=SystemColors.GrayTextBrush}" Style="{x:Null}" Grid.Row="4" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<ListBox Grid.Column="2" Grid.Row="4" ItemsSource="{Binding Source={StaticResource xdp1}}" DisplayMemberPath="@Name"/>
</Grid>
<local:MyTextBlock Text="Hello" x:Name="myTextBlock1"/>
<local:MyTextBlock Text="Hello"/>
</StackPanel>
</Window.Content>
</Window>

3.总结

这次主要是介绍Xaml相关的内容,讲的都是一些基础。自己在手写的过程,也重拾了已经遗忘的知识!

4.参考文献

1.MSDN(http://msdn.microsoft.com/zh-cn/library/ms754130%28v=vs.110%29.aspx)

2.深入浅出WPF(刘铁猛)

3.WPF高级编程

5.Xaml编译(补充内容)

Xaml的编译主要做三件事:

  1.转换为特殊的二进制格式Baml

  2.将Baml作为二进制资源嵌入程序集

  3.将Xaml和过程式代码链接起来

WPF学习(2)XAML的更多相关文章

  1. WPF学习笔记-用Expression Design制作矢量图然后导出为XAML

    WPF学习笔记-用Expression Design制作矢量图然后导出为XAML 第一次用Windows live writer写东西,感觉不错,哈哈~~ 1.在白纸上完全凭感觉,想象来画图难度很大, ...

  2. 学习WPF——了解WPF中的XAML

    XAML的简单说明 XAML是用于实例化.NET对象的标记语言,主要用于构建WPF的用户界面 XAML中的每一个元素都映射为.NET类的一个实例,例如<Button>映射为WPF的Butt ...

  3. WPF学习05:2D绘图 使用Transform进行控件变形

    在WPF学习04:2D绘图 使用Shape绘基本图形中,我们了解了如何绘制基本的图形. 这一次,我们进一步,研究如何将图形变形. 例子 一个三角形,经Transform形成组合图形: XAML代码: ...

  4. WPF学习之资源-Resources

    WPF学习之资源-Resources WPF通过资源来保存一些可以被重复利用的样式,对象定义以及一些传统的资源如二进制数据,图片等等,而在其支持上也更能体现出这些资源定义的优越性.比如通过Resour ...

  5. WPF学习之路初识

    WPF学习之路初识   WPF 介绍 .NET Framework 4 .NET Framework 3.5 .NET Framework 3.0 Windows Presentation Found ...

  6. WPF学习拾遗(二)TextBlock换行

    原文:WPF学习拾遗(二)TextBlock换行 下午在帮组里的同事解决一个小问题,为了以后方便,把就把它收集一下吧. 新建一个TextBlock作为最基础的一个控件,他所携带的功能相对于其他的控件要 ...

  7. WPF学习(8)数据绑定

    说到数据绑定,其实这并不是一个新的玩意儿.了解asp.net的朋友都知道,在asp.net中已经用到了这个概念,例如Repeater等的数据绑定.那么,在WPF中的数据绑定相比较传统的asp.net中 ...

  8. WPF 学习笔记-在WPF下创建托盘图标

    原文:WPF 学习笔记-在WPF下创建托盘图标 首先需要在项目中引用System.Windows.Forms,System.Drawing; using System; using System.Co ...

  9. (转)WPF学习资源整理

    由于笔者正在学习WPF,所以整理出网络中部分WPF的学习资源,希望对同样在学习WPF的朋友们有所帮助. 首推刘铁猛的<深入浅出WPF>系列博文 1.深入浅出WPF(1)——什么是WPFht ...

  10. WPF学习资源整理

    WPF(WindowsPresentation Foundation)是微软推出的基于Windows Vista的用户界面框架,属于.NET Framework 3.0的一部分.它提供了统一的编程模型 ...

随机推荐

  1. 解决错误 fatal error C1010: unexpected end of file while looking for precompiled head

    在编译VS时候,出现fatal error C1010: unexpected end of file while looking for precompiled head. 问题详解:致命错误C10 ...

  2. mysql经常使用的命令

    如何登陆数据库     飞机着陆     mysql -u <username> -p     访问本机数据库     mysql -u <username> -D <d ...

  3. android创建自定义对话框

    创建如下自定义对话框: JAVA代码 LayoutInflater li = LayoutInflater.from(TagActivity. this);  //NOTE final View Te ...

  4. 建立Hibernate二级Cache

    建立Hibernate二级Cache它需要两个步骤:首先,一定要使用什么样的数据并发策略,然后配置缓存过期时间,并设置Cache提供器. 有4种内置的Hibernate数据并发冲突策略,代表数据库隔离 ...

  5. fscanf()功能具体解释

    一旦文件被解析常规时间或使用正则表达式.或者是敲自己太傻代码来解析一个普通文件. 今天突然发现c该图书馆有一个现成的文件可以解析常规功能,这是fscanf()功能.哎 曾经自己做了这么多无用功.在这里 ...

  6. mongodb笔记2

    成功启动MongoDB后,再打开一个命令行窗口输入mongo,就可以进行数据库的一些操作. 输入help可以看到基本操作命令: show dbs:显示数据库列表 show collections:显示 ...

  7. 【原创】java中的父进程子进程 —— 坑爹的java Runtime.getRuntime().exec

    最近有一个需求,需要用一个java进程启动多个子进程来完成并发任务.由于必须给用户完成任务的反馈,所以需要父进程记录子进程的生命周期. exec方法返回一个Process对象,在当前进程内调用该对象的 ...

  8. 【BZOJ 1642】 [Usaco2007 Nov]Milking Time 挤奶时间

    1642: [Usaco2007 Nov]Milking Time 挤奶时间 Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 590  Solved: 3 ...

  9. linux如何执行后台进程

    linux直接执行一个过程.电流指令结束后.或者关闭掉shell形成过程将结束. 如何在后台执行的处理 办法1 采用nohup命令,nohup命令本身的意思no hung up他说,他们将不会收到sh ...

  10. 乐在其中设计模式(C#) - 解释器模式(Interpreter Pattern)

    原文:乐在其中设计模式(C#) - 解释器模式(Interpreter Pattern) [索引页][源码下载] 乐在其中设计模式(C#) - 解释器模式(Interpreter Pattern) 作 ...