<Page x:Class="ExpanderDirectionExample.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0">
<Expander Name="myExpander" Background="Tan"
HorizontalAlignment="Left" Header="My Expander"
ExpandDirection="Down" IsExpanded="True" Width="100">
<TextBlock TextWrapping="Wrap">
this is a test
</TextBlock>
</Expander>
</StackPanel>
<StackPanel Grid.Column="1" Grid.Row="0">
<TextBlock Margin="0, 10, 3, 3" FontSize="12" TextWrapping="Wrap">
Click to change the ExpandDirection property on My Expander
</TextBlock>
<StackPanel>
<RadioButton Name="ExpandDown" Margin="0,10,0,10"
IsChecked="True"
Checked="ChangeExpandDirection"
GroupName="ExpandDirectionProperty">
Expand Down
</RadioButton>
<RadioButton Name="ExpandUp" Margin="0,0,0,10"
Checked="ChangeExpandDirection"
GroupName="ExpandDirectionProperty">
Expand Up
</RadioButton>
<RadioButton Name="ExpandLeft" Margin="0,0,0,10"
Checked="ChangeExpandDirection"
GroupName="ExpandDirectionProperty">
Expand Left
</RadioButton>
<RadioButton Name="ExpandRight" Margin="0,0,0,10"
Checked="ChangeExpandDirection"
GroupName="ExpandDirectionProperty">
Expand Right
</RadioButton>
</StackPanel>
</StackPanel>
</Grid>
</Page>
//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Media
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Namespace ExpanderDirectionExample
Public Partial Class Page1
Inherits Page
Private Sub ChangeExpandDirection(sender As Object, e As RoutedEventArgs)
If CType(ExpandDown.IsChecked, [Boolean]) Then
myExpander.ExpandDirection = ExpandDirection.Down
ElseIf CType(ExpandUp.IsChecked, [Boolean]) Then
myExpander.ExpandDirection = ExpandDirection.Up
ElseIf CType(ExpandLeft.IsChecked, [Boolean]) Then
myExpander.ExpandDirection = ExpandDirection.Left
ElseIf CType(ExpandRight.IsChecked, [Boolean]) Then
myExpander.ExpandDirection = ExpandDirection.Right
End If
myExpander.IsExpanded = True
End Sub
End Class
End Namespace
|