上一篇文章简单说了一下Expander控件,本文将编写一个自义模板的Expander控件,如下图所示:
<Window x:Class="Expander_Sample2.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">
<Window.Resources>
<!--
ToogleButton的模板,
因为要进和状态切换,故要用到ToggleButton控件
-->
<ControlTemplate x:Key="ToggleButtonTemp" TargetType="{x:Type ToggleButton}">
<Border x:Name="bd"
BorderThickness="1"
CornerRadius="1,1,1,1">
<Border.Background>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="LightGray" Offset="0"/>
<GradientStop Color="White" Offs