Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法在矩形区域WPF C中拖放文件或文件夹#_C#_Wpf - Fatal编程技术网

C# 无法在矩形区域WPF C中拖放文件或文件夹#

C# 无法在矩形区域WPF C中拖放文件或文件夹#,c#,wpf,C#,Wpf,这是我的XAML <Grid> <Grid.RowDefinitions> <RowDefinition Height="8*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <ProgressBar Grid.Row="1" Is

这是我的XAML

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="8*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <ProgressBar Grid.Row="1" IsIndeterminate="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Foreground="#02F4C4" Value="{Binding CurrentProgress}"/>
    <TextBlock Grid.Row="1" Text="{Binding CurrentProgressText}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="22"/>

    <ProgressBar Grid.Row="2" IsIndeterminate="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Foreground="#02F432" Value="{Binding OverallProgress}"/>
    <TextBlock Grid.Row="2" Text="{Binding OverallProgressText}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="22"/>

    <Rectangle Grid.Row="0" Fill="#CCCCCC" HorizontalAlignment="Stretch" Stroke="Black" VerticalAlignment="Stretch" AllowDrop="True" DragOver="Rectangle_DragOver" Drop="Rectangle_Drop" DragEnter="Rectangle_DragOver" Visibility="{Binding DragDropVisibility}"/>
    <TextBlock Grid.Row="0" Text="Drag folder(s) here to start" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" AllowDrop="True" DragOver="Rectangle_DragOver" Drop="Rectangle_Drop" DragEnter="Rectangle_DragOver" Visibility="{Binding DragDropVisibility}"/>
</Grid>

我的错在哪里?出什么问题了?

我刚刚编写了代码,并试图在该区域上拖动一个文件:虽然鼠标是“不可用”指针,但两个方法都被我命中。检查绑定属性中的错误,其余一切看起来都很好。不存在绑定错误。。。我尝试了一个非常基本的例子,没有行和其他东西。。。我在ProgressBar上也添加了AllowDrop,但事情是一样的。如果从Visual Studio 2019进行调试,您能相信它不起作用,但它在Visual Studio 2017中工作得很好吗?该死的微软!可能是重复的我刚刚编写了代码并试图在区域上拖动一个文件:虽然鼠标是“不可用”指针,但两个方法都被我命中。检查绑定属性中的错误,其余一切看起来都很好。不存在绑定错误。。。我尝试了一个非常基本的例子,没有行和其他东西。。。我在ProgressBar上也添加了AllowDrop,但事情是一样的。如果从Visual Studio 2019进行调试,您能相信它不起作用,但它在Visual Studio 2017中工作得很好吗?该死的微软!可能重复的
private void Rectangle_DragOver(object sender, DragEventArgs e)
{
    //e.Effects = DragDropEffects.None;

    if (e.Data.GetDataPresent(DataFormats.FileDrop))
    {
        var files = e.Data.GetDataPresent(DataFormats.FileDrop);

        e.Effects = DragDropEffects.Copy | DragDropEffects.Move;
    }
}

private void Rectangle_Drop(object sender, DragEventArgs e)
{

}