2

我有一个网格,其中包含同一级别的 Canvas 和 StackPanel。我的意思是放置在画布顶部的 StackPanel。画布包含多个应该可以拖动的元素。我必须处理 StackPanel 的 Drop 事件。如果 stackpanel 不包含任何子元素,即使我设置了 stackpanel 的高度,drop 事件也不起作用。如果我为 StackPanel 设置 Background 属性,它将起作用,但在这种情况下,画布子元素(在堆栈面板下方)的 mousemove 事件不起作用。

这是 XAML

<Grid>
        <jas:DragCanvas 
            x:Name="dragCanvas"
            Grid.Row="1" 
            AllowDragging="{Binding ElementName=btnAllowDragging, Path=IsChecked}"
            AllowDragOutOfView="{Binding ElementName=btnAllowDragOutOfView, Path=IsChecked}"
            >
            <Ellipse
                Canvas.Left="100" Canvas.Bottom="100"
                Width="65" Height="70">
                <Ellipse.Fill>
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                        <LinearGradientBrush.GradientStops>
                            <GradientStop Color="LightGray" Offset="0" />
                            <GradientStop Color="Black" Offset="0.75" />
                        </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                </Ellipse.Fill>
            </Ellipse>
        </jas:DragCanvas>
        <DockPanel LastChildFill="False">
            <Border DockPanel.Dock="Left" BorderBrush="Black" BorderThickness="2">
                <StackPanel x:Name="stackPanel" Drop="StackPanel_Drop" AllowDrop="True">
                    <Border Height="100" Width="100" Background="Red"></Border>
                </StackPanel>
            </Border>
        </DockPanel>
    </Grid>
4

0 回答 0