UI即是User Interface用户界面的简称。UI设计则是指对软件的人机交互/操作逻辑/界面美观的整体设计。好的UI设计不仅是让软件变得有个性品味,还要让软件的操作变得舒适/简单/自由,充分体现软件定位和特点。
Windows.UI.Xaml.Controls,它提供UI的控件和类,不仅支持现有的控件和类,也支持自定义的控件和类。例如Windows提供的类有AppBar/Border/Button/Canvas。每个class都有不同的功用,正如AppBar是代表容器的控件。Border是用来绘制一个边框背景的控件。Button是一个按钮控件,可用在点击信息交互上。
Windows.UI.Xaml.Controls.Primitives,这个空间主要用来定义UI控件组成部分的类或者支持控件组合模型的类,也定义了接口控制模式。例如snapping和selection。它的类有ButtonBase/Popup/RangeBase/Thumb。WinJs.UI它提供控制和操作数据的对象。例题1如下:
<Border Background="Coral" Width="300" Padding="10" CornerRadius="20"> <TextBlock FontSize="16">Text Surrounded by a Border</TextBlock> </Border> <Canvas Width="640" Height="480" > <Rectangle Canvas.Left="30" Canvas.Top="30" Fill="Red" Width="200" Height="200" /> </Canvas> <AppBar x:Name="bottomAppBar" Padding="10,0,10,0"> <Grid> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <Button Style="{StaticResource HelpAppBarButtonStyle}" Click="Button_Click"/> </StackPanel> </Grid> </AppBar>
Windows.UI.WebUI提供激活,暂停或恢复应用程序的机制。例如Activated Operation是用来管理程序激活操作的。SuspendingOperation用来暂停程序。WebUIApplication用来接收激活/暂停/恢复信息的。
Windows.UI.Xaml提供Framework和应运程序的API以及支持各种不同功能区域的类。例如Application/DispatcherTimer/DependencyProperty。其中依赖属性是XAML的重要功能表现之一。
Windows.UI.Xaml.Hosting是提供相关Xaml表面设计服务的托管程序。例子2是关于依赖属性的。
public class Fish : Control { public static readonly DependencyProperty SpeciesProperty = DependencyProperty.Register( "Species", typeof(String), typeof(Fish), null ); public string Species { get { return (string)GetValue(SpeciesProperty); } set { SetValue(SpeciesProperty, (string)value); } } }