《深入淺出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#代碼
程序設計圖:
程序運行圖: