在 WPF 中,我們可以方便的在全局范圍定義一個樣式,就可以應(yīng)用到所有這種類型的對象,這就是所謂的隱式樣式(implicit Style),比如:

WPF中定義樣式
<Window x:Class="WpfImplicitStyle.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.Resources>
<!-- 針對一種類型設(shè)置全局樣式 -->
<Style TargetType="Button">
<Setter Property="Background" Value="AliceBlue" />
</Style>
</Grid.Resources>
<StackPanel>
<Button>Button a</Button>
<Button>Button b</Button>
</StackPanel>
</Grid>
</Window>
NET技術(shù):Silverlight 里如何實現(xiàn)隱式樣式,ImplicitStyleManager 的實現(xiàn)思想,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。