Win8風格的WPF按鈕

Win8將Windows的風格又進行了一次變革,我還挺喜歡的,有簡潔大氣的感受,華麗絢麗的東西看多了以後總會返璞歸真尋找簡潔大氣的感受才能心情舒暢。優化

下面就給個WPF下Button的自定義寫法。spa

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<Button Content="Im Button! Click Me。" Height="94" HorizontalAlignment="Left" Name="button1" VerticalAlignment="Top" Width="174" Foreground="#FFFCFCFC" FontSize="18" FontWeight="Bold">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border BorderBrush="Transparent" BorderThickness="0" Background="#FFc6178a" Name="PART_Background">
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Border.Background" TargetName="PART_Background" Value="#FFe923a5" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>

哈哈,看了上面代碼是否是有種上當的感受啊??code

其實只是像而已,其實上面的代碼會消耗點內存,能夠再優化的,可是如今內存飆升,動輒N個G的內存來講也不會有啥影響。xml

相關文章
相關標籤/搜索