当扩展器折叠时如何访问扩展器下的对象?

发布于 2024-10-09 04:24:19 字数 268 浏览 0 评论 0原文

嗨,大家好 我有这样的代码,

<RichTextBox />
  <Expander Header="expand">
   <Grid>
    <Rectangle />
   </Grid>
  </Expander>

虽然我已经折叠了扩展器,但我仍然无法访问richtextbox,因为richtextbox位于扩展器层下。 当扩展器折叠时我如何访问richtextbox?

hi guys
i have a code like this

<RichTextBox />
  <Expander Header="expand">
   <Grid>
    <Rectangle />
   </Grid>
  </Expander>

although i already collapse the expander, i still cant access richtextbox, because richtextbox under layer of expander.
how i can access richtextbox when expander is collapse?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

就像说晚安 2024-10-16 04:24:19

如果您将对象放置在网格的同一行和同一列中,它们将会重叠。这两个对象都位于网格的第 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>

If you're laying out objects in the same row and column of a grid, they're going to overlap. Both of those objects are in row 0 and column 0 of the grid.

I'm not sure what you're trying to accomplish. If you don't want the objects to overlap, use a DockPanel or StackPanel to lay them out, or if you're going to use a grid, put them in different rows, e.g.:

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文