扩展的文本框在WPF中其他元素的后面

问题描述 投票:-1回答:1

这是我第一次使用C#学习WPF。所以我有一个文本框,当我单击一个按钮时,该文本框会扩展。问题是当我扩展它时,它仍然留在其他元素(文本框等)的后面。

这里是文本框的xml代码。

<StackPanel Grid.Column="1" Grid.ColumnSpan="4" Grid.Row="3" Grid.RowSpan="5" Panel.ZIndex="0" Visibility="Collapsed" Name="descriptionPanel" Margin="2,0,0,0" Background="White">
            <Border BorderBrush="DarkGray" BorderThickness="1" CornerRadius="5">
                <StackPanel Orientation="Horizontal">
                    <TextBox Name="descriptionTextBoxExtended" 
                     Margin="10,10,10,10" 
                     Style="{StaticResource expandedTextBox}"
                     Text="{Binding Path=Description, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, TargetNullValue=''}"                     
                     IsReadOnly="{Binding RelativeSource={RelativeSource AncestorLevel=1,AncestorType=Control}, Path=SecurityLevel2ReadOnly, Mode=OneWay}"
                  />
                    <Button Name="descriptionHide"  Style="{StaticResource MinusButton}"  HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,10,10" Click="descriptionHide_Click" />
                </StackPanel>
            </Border>
        </StackPanel>

这里是C#

private void exDescription_Click(object sender, RoutedEventArgs e)
    {
        descriptionPanel.Visibility = Visibility.Visible;
    }

这是我在单击扩展按钮之前运行它时的外观:enter image description here

这是我扩展文本框时的外观:enter image description here

我希望所有突出显示的组件都在文本框后面。

这是我第一次使用C#学习WPF。所以我有一个文本框,当我单击一个按钮时,该文本框会扩展。问题是当我扩展它时,它仍然留在其他元素(文本框等)的后面。

c# wpf textbox
1个回答
0
投票

您应该给我们“ descriptionPanel”旁边其他元素的代码,但是正如mm8所指出的,您的元素似乎不在同一Panel中。

© www.soinside.com 2019 - 2024. All rights reserved.