T
T
Timur Yakubov2019-09-16 21:04:35
WPF
Timur Yakubov, 2019-09-16 21:04:35

Why is Allow Drop not working?

Allow Drop does not work properly.
In a finished project from the Internet, Allow Drop works fine both in this way and in debugging.
I copy the code to a clean project, it does not work in debugging, but it works without.
It refuses to work in my project.
I tried to assign it to different elements, but without a result, the triggers do not work accordingly.
The project uses Nuget Material Design (tried without it, no result).

<Window x:Class="AChecker.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:AChecker"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="600">
    <Grid>
        <Rectangle Fill="#FF404552" />
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="170" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="1">
                <materialDesign:Card Background="#FF5C869B" Width="400" Height="250" HorizontalAlignment="Center"
                                     VerticalAlignment="Center" />
                <Grid Width="400" Height="250">
                    <Grid x:Name="Grid_MenuClean">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="50" />
                        </Grid.RowDefinitions>
                        <TextBox x:Name="TextBoxCleanOutput" HorizontalAlignment="Center" VerticalAlignment="Center"
                                 Width="350" Height="180" Background="#FF575C68" FontFamily="Yu Gothic UI Semilight"
                                 FontSize="14" />
                        <Button x:Name="ButtonCleanStart" Grid.Row="1" Width="150" Background="#FF497891"
                                BorderBrush="#FF497891" Content="Анализ и очистка" Click="ButtonCleanStart_Click" />
                        <Grid Width="390" Height="190" Visibility="Hidden">
                            <ScrollViewer x:Name="Scroller" Margin="0" Background="#FF575C68"
                                          VerticalScrollBarVisibility="Auto">
                                <TextBlock x:Name="Analyze_OutputBlock" Foreground="White"
                                           FontFamily="Leelawadee UI Semilight" HorizontalAlignment="Center"
                                           VerticalAlignment="Center" Margin="30,0,0,0" Width="400" Height="200"
                                           FontSize="14" />
                            </ScrollViewer>

                        </Grid>
                        <Rectangle HorizontalAlignment="Center" VerticalAlignment="Center" Width="350" Height="180"
                                   Fill="#00000000" />
                    </Grid>
                </Grid>
            </Grid>
            <Grid Grid.Column="0" Height="260" Width="160" Margin="0,30,0,0" VerticalAlignment="Top">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Button Content="Главное" Background="#FF5C869B" BorderBrush="#FF5C869B" />
                <Button Content="Дополнительно" Grid.Row="1" Background="#FF5C869B" BorderBrush="#FF5C869B" />
                <Button Content="Фон. работа" Grid.Row="2" Background="#FF5C869B" BorderBrush="#FF5C869B" />
                <Button x:Name="ButtonMenuHelp" Content="Помощь" Grid.Row="3" Background="#FF5C869B"
                        BorderBrush="#FF5C869B" Click="ButtonMenuHelp_Click" />
            </Grid>
            <Grid Grid.Column="0" Height="90" Drop="ImageTrasher_Drop" VerticalAlignment="Bottom">
                <Rectangle Fill="Black" AllowDrop="True">

                </Rectangle>
                <Image x:Name="ImageTrasher" Source="Resources/trasher.png" Width="90" Height="60" VerticalAlignment="Bottom" Margin="0,0,0,10" Drop="ImageTrasher_Drop" AllowDrop="True" PreviewDragOver="ImageTrasher_PreviewDragOver" DragEnter="ImageTrasher_DragEnter" MouseMove="ImageTrasher_MouseMove"/>
            </Grid>
        </Grid>
    </Grid>
</Window>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Timur Yakubov, 2019-09-18
@Kaidoz

The problem was solved by the usual restart of Visual Studio 2019. Apparently, some bug was caught.

A
Alexander Yudakov, 2019-09-17
@AlexanderYudakov

AllowDrop alone is indispensable here.
https://professorweb.ru/my/WPF/base_WPF/level5/5_12.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question