问题描述
怎么改变Expander的头部分,就是他的头都由自己用图片拼成不同的样式可以吗,希望诸位能帮帮忙,给个小Dome看看也行的,谢谢了。
解决方案
解决方案二:
MSDN有现成的例子[code=XAML]<!--<SnippetExpander>--><ControlTemplatex:Key="ExpanderToggleButton"TargetType="ToggleButton"><BorderName="Border"CornerRadius="2,0,0,0"Background="Transparent"BorderBrush="{StaticResourceNormalBorderBrush}"BorderThickness="0,0,1,0"><PathName="Arrow"Fill="{StaticResourceGlyphBrush}"HorizontalAlignment="Center"VerticalAlignment="Center"Data="M00L44L80Z"/></Border><ControlTemplate.Triggers><TriggerProperty="ToggleButton.IsMouseOver"Value="true"><SetterTargetName="Border"Property="Background"Value="{StaticResourceDarkBrush}"/></Trigger><TriggerProperty="IsPressed"Value="true"><SetterTargetName="Border"Property="Background"Value="{StaticResourcePressedBrush}"/></Trigger><TriggerProperty="IsChecked"Value="true"><SetterTargetName="Arrow"Property="Data"Value="M04L40L84Z"/></Trigger><TriggerProperty="IsEnabled"Value="False"><SetterTargetName="Border"Property="Background"Value="{StaticResourceDisabledBackgroundBrush}"/><SetterTargetName="Border"Property="BorderBrush"Value="{StaticResourceDisabledBorderBrush}"/><SetterProperty="Foreground"Value="{StaticResourceDisabledForegroundBrush}"/><SetterTargetName="Arrow"Property="Fill"Value="{StaticResourceDisabledForegroundBrush}"/></Trigger></ControlTemplate.Triggers></ControlTemplate><StyleTargetType="Expander"><SetterProperty="Template"><Setter.Value><ControlTemplateTargetType="Expander"><Grid><Grid.RowDefinitions><RowDefinitionHeight="Auto"/><RowDefinitionName="ContentRow"Height="0"/></Grid.RowDefinitions><BorderName="Border"Grid.Row="0"Background="{StaticResourceLightBrush}"BorderBrush="{StaticResourceNormalBorderBrush}"BorderThickness="1"CornerRadius="2,2,0,0"><Grid><Grid.ColumnDefinitions><ColumnDefinitionWidth="20"/><ColumnDefinitionWidth="*"/></Grid.ColumnDefinitions><ToggleButtonIsChecked="{BindingPath=IsExpanded,Mode=TwoWay,RelativeSource={RelativeSourceTemplatedParent}}"OverridesDefaultStyle="True"Template="{StaticResourceExpanderToggleButton}"Background="{StaticResourceNormalBrush}"/><ContentPresenterGrid.Column="1"Margin="4"ContentSource="Header"RecognizesAccessKey="True"/></Grid></Border><BorderName="Content"Grid.Row="1"Background="{StaticResourceWindowBackgroundBrush}"BorderBrush="{StaticResourceSolidBorderBrush}"BorderThickness="1,0,1,1"CornerRadius="0,0,2,2"><ContentPresenterMargin="4"/></Border></Grid><ControlTemplate.Triggers><TriggerProperty="IsExpanded"Value="True"><SetterTargetName="ContentRow"Property="Height"Value="{BindingElementName=Content,Path=DesiredHeight}"/></Trigger><TriggerProperty="IsEnabled"Value="False"><SetterTargetName="Border"Property="Background"Value="{StaticResourceDisabledBackgroundBrush}"/><SetterTargetName="Border"Property="BorderBrush"Value="{StaticResourceDisabledBorderBrush}"/><SetterProperty="Foreground"Value="{StaticResourceDisabledForegroundBrush}"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style>[/code]
解决方案三:
学习