Customizing Appearance by Using Windows® Presentation Foundation

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.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值