正如我在标题中所说的,当关闭按钮被按下时,我需要关闭与stackpanel项目交互的按钮。但我是wpf新手,不知道如何将stackpanel或按钮与特定的stackpanel项目绑定。你能帮助我吗?
`<DataTemplate x:Key="fixTemplate">
<Grid Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Center">
<StackPanel x:Name="fixPanel" MouseWheel="StackPanel_MouseWheel">
<Border BorderThickness="1" CornerRadius="10" Opacity="1.0" Background="{dxi:ThemeResource {dxmt:MapBrushesThemeKey ResourceKey=OverlayBackground}}">
<StackPanel Orientation="Vertical" Margin="8">
<Button x:Name="fixButton" Uid="0++" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type StackPanel}}}" Content="X" Background="Red" Width="25" Height="25" HorizontalAlignment="Right" Click="fixButton_Click"/>
<TextBlock x:Name="fixText" Text="{Binding ToolTipText}" Foreground="{dxi:ThemeResource {dxmt:MapBrushesThemeKey ResourceKey=OverlayElementForeground}}" TextWrapping="Wrap"/>
</StackPanel>
</Border>
<Path Stretch="Fill"
Data="m 66.709675,141.93548 29.096774,-33 27.677421,33.35484 -18.80645,-0.35484 0.70968,43.29032 H 87.64516 l -0.709676,-43.29032 z"
HorizontalAlignment="Center"
Height="15"
Width="20"
UseLayoutRounding="False"
VerticalAlignment="Center"
Stroke="#BF000000"
StrokeThickness="0.4"
Margin="-13 0 0 0" >
<Path.Effect>
<DropShadowEffect ShadowDepth="2" BlurRadius="7" Opacity="0.5"/>
</Path.Effect>
<Path.Fill>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1." />
</RadialGradientBrush>
</Path.Fill>
</Path>
</StackPanel>
</Grid>
</DataTemplate>`
正如你所看到的,我有一个按钮和动态创建的堆栈面板。我如何删除它的按钮被点击的堆栈面板?
我试图删除stackpanel,它是在它的删除按钮,但每个stackpanel被删除在我的代码。我不知道如何指定哪个stackpanel将删除时,该stackpanel的关闭按钮被按下
1条答案
按热度按时间tpxzln5u1#
我尝试的代码是这样的