简单例子

代码

  1. <Grid>
  2. <Grid.RowDefinitions>
  3. <RowDefinition Height="20"/>
  4. <RowDefinition Height="Auto"/>
  5. <RowDefinition Height="*"/>
  6. </Grid.RowDefinitions>
  7. <Expander
  8. Grid.Row="1"
  9. Name="myExpander"
  10. Width="100"
  11. HorizontalAlignment="Center"
  12. Background="Tan"
  13. ExpandDirection="Down"
  14. Header="My Expander"
  15. IsExpanded="True" >
  16. <TextBlock TextWrapping="Wrap">
  17. You can set the content area of an Expander control to expand in one
  18. of four directions (Down, Up, Left, or Right) by using the
  19. ExpandDirection property. When the content area is collapsed,
  20. only the ExpanderHeader and its toggle button appear. A Button
  21. control that displays a directional arrow is used as a toggle button
  22. to expand or collapse the content area. When expanded, the Expander
  23. tries to display all of its content in a window-like area.
  24. </TextBlock>
  25. </Expander>
  26. </Grid>

效果

expander sample.gif