如何在崩溃时访问扩展器下的对象?

时间:2010-12-26 09:27:28

标签: wpf richtextbox expand layer

嗨,伙计们 我有这样的代码

<RichTextBox />
  <Expander Header="expand">
   <Grid>
    <Rectangle />
   </Grid>
  </Expander>
虽然我已经崩溃了扩展器,但我仍然无法访问richtextbox,因为richtextbox在扩展器层下。 如何在展开器崩溃时访问richtextbox?

1 个答案:

答案 0 :(得分:1)

如果您在网格的同一行和列中布置对象,它们将重叠。这两个对象都在网格的第0行和第0列。

我不确定你要完成什么。如果您不希望对象重叠,请使用DockPanelStackPanel进行布局,或者如果您要使用网格,请将它们放在不同的行中,例如:

<Grid>  
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="Auto"/>
  </Grid.RowDefinitions>
  <RichTextBox Grid.Row="0">
    <FlowDocument>
       <Paragraph>
        <Run Text="Now this doesn't overlap."/>
       </Paragraph>
    </FlowDocument>
  </RichTextBox>
  <Expander Header="expand" Grid.Row="1">
  <Grid>
    <Rectangle />
  </Grid>
  </Expander>
</Grid>
相关问题