index > Windows Presentation Foundation ("Avalon") > Expander: Place expand button on the right?

Expander: Place expand button on the right?

Hello all.

How can I template the header of the expand control, so that the expand button is placed on the right side of the header text?

Best regards.

Biggo

change the template for the expander

here is a sample

<Style TargetType="{x:Type Expander}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Expander}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Name="ContentRow" Height="0"/>
</Grid.RowDefinitions>
<Border
Name="Border"
Grid.Row="0"
Background="{StaticResource LightBrush}"
BorderBrush="{StaticResource NormalBorderBrush}"
BorderThickness="1"
CornerRadius="2,2,0,0" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<ToggleButton Grid.Column="1"
IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
OverridesDefaultStyle="True"
Template="{StaticResource ExpanderToggleButton}"
Background="{StaticResource NormalBrush}" />
<ContentPresenter
Grid.Column="0"
Margin="4"
ContentSource="Header"
RecognizesAccessKey="True" />
</Grid>
</Border>
<Border
Name="Content"
Grid.Row="1"
Background="{StaticResource WindowBackgroundBrush}"
BorderBrush="{StaticResource SolidBorderBrush}"
BorderThickness="1,0,1,1"
CornerRadius="0,0,2,2" >
<ContentPresenter Margin="4" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter TargetName="ContentRow" Property="Height" Value="{Binding ElementName=Content,Path=DesiredHeight}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}" />
<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
<Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
</Trigger>

</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

lee d
reply 2

You can use google to search for other answers

 

More Articles

• Managing Navigation Exceptions
• RichTextBox, insert an Inline element at CaretPosition (in an exi...
• ICollectionView grouping
• sparkle correct version
• Moving objects around in a Viewport3D using mouse ?
• ContextMenu : Cannot find TargetName in scope of System.Windows.C...
• Mouse Position Relative to Desktop 0 0
• Design and Generics
• ListBox item scroll animation
• Pass mouseevents to Inkcanvas childobjects
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Render buttons without border
• Adding new event handler to custom contr
• problem launching xbap application in Me
• How do I scroll a TreeViewItem into view?
• Relative Image Path
• I am not able to install Orcas Technolog
• Question about the default window create
• Where can i get information about Attrib
• winfx wizard framework
• RichTextBox, insert an Inline element at
• how to pass URL query strings from one x
• Issue with WPF Designer in Vista Build 5
• ListBox item scroll animation
• TreeView with label editing
• Managing Navigation Exceptions

Hot Articles

• When is Binding.ElementName non-NULL?
• WPF Text blurry
• how to get data from listview
• How to pass parameters to a DataBinding
• Executing Commands from *any* event
• XAMLPad for June CTP neeeeeeded
• Intellisense Problem in XAML
• Textbox default contextmenu Style
• Skyboxes in WPF
• Binding to Combobox.Text when IsSynchron
• Render buttons without border
• Custom Control - Generic.baml file not g
• Bind To Method Topic is missing from dow
• DP of type BindingBase and XAML
• PropertyGrid

Recommend Articles

• WPF Architectural Question
• ContextMenu for GridViewColumn
• Rounded edges cube mesh
• Distance between 3d objects / world coor
• RichTextBox, turn off the Keyboard-langu
• Repeating controls
• How to assign database/source of ListVie
• Memory Leak problem when using bitmap im
• Updated samples for RC1
• MouseUp/MouseDown/MouseClick
• animate listbox items to scroll
• MediaElement is playing HD-movies slow i
• Setting my window to Bottommost, or Alwa
• Navigation Window: Can it be Like a web
• Anyway to change WindowsFormsHost z-orde