WPF模板-Style中的Setter

《深入浅出WPF》(作者:刘铁猛)之学习笔记

WPF模板-Style中的Setter

XAML代码:

<Window x:Class="Style中的Setter.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Style中的Setter"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Style TargetType="TextBlock">
            <Style.Setters>
                <Setter Property="FontSize" Value="24"/>
                <Setter Property="TextDecorations" Value="Underline"/>
                <Setter Property="FontStyle" Value="Italic"/>
            </Style.Setters>
        </Style>
    </Window.Resources>
    <StackPanel Margin="5">
        <TextBlock Text="Hello WPF"/>
        <TextBlock Text="This is a simple for Style"/>
        <TextBlock Text="by Tim 2009.12.23" Style="{x:Null}"/>
    </StackPanel>
</Window>

无C#代码
程序设计图:
这里写图片描述
程序运行图:
这里写图片描述

posted on 2017-09-23 09:55  五月槐花  阅读(1974)  评论(0编辑  收藏  举报

导航