扩展文本框落后于 WPF 中的其他元素
Extended Textbox is behind other elements in WPF
这是我第一次用 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;
}
这是我 运行 在单击扩展按钮之前的样子:
这就是我扩展文本框时的样子:
我希望所有突出显示的组件都在文本框后面。
你应该给我们"descriptionPanel"旁边的其他元素的代码,但正如mm8指出的那样,你的元素似乎不在同一个Panel中。
这是我第一次用 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;
}
这是我 运行 在单击扩展按钮之前的样子:
这就是我扩展文本框时的样子:
我希望所有突出显示的组件都在文本框后面。
你应该给我们"descriptionPanel"旁边的其他元素的代码,但正如mm8指出的那样,你的元素似乎不在同一个Panel中。