您的位置:首页 > 移动开发

Customizing Appearance by Using Windows® Presentation Foundation

2010-04-29 10:45 369 查看
Sharing Logical Resources in an Application

WPF enables you to separate common objects and resources so that you can reuse them across applications or isolate them for localization. You can reference resources in XAML or programmatically.

Creating Consistent User Interfaces by Using Styles

WPF enables you to define UIs that have a consistent look and feel by using styles and themes to share properties, resources, and event handlers.

Style:支持BasedOn(继承),也是一种Resource;Trigger,Setter等。为控件设置统一的样式。

<Application.Resources>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Background" Value="Red"></Setter>
</Trigger>
</Style.Triggers>
<Style.Setters>
<Setter Property="Foreground">
<Setter.Value>
Yellow
</Setter.Value>
</Setter>

<Setter Property="Text" Value="default value">

</Setter>
</Style.Setters>
</Style>
<Style BasedOn="{StaticResource {x:Type TextBox}}" x:Key="MyTextBox" TargetType="TextBox">
<Style.Setters>
<Setter Property="Foreground" Value="Red"></Setter>
</Style.Setters>
</Style>
</Application.Resources>


Changing the Appearance of Controls by Using Templates

The WPF templating model enables you to modify the appearance and behaviors of content controls and item controls. You can use template binding to enable the user to change the values of certain control properties.

Enhancing User Interfaces by Using Triggers and Animations

WPF enables you to enhance the UI and create visually compelling effects by using triggers and animations to change an application's appearance based on user interactions.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐