<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dockpane with listed files: drag&amp;amp;drop method to add files to map does not work. where's the issue? in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/dockpane-with-listed-files-drag-amp-drop-method-to/m-p/1326240#M12090</link>
    <description>&lt;P&gt;Thank you for your quick response. Honestly, I'm not sure.&amp;nbsp; I don't see the mouse change from the arrow to the forbidden-sign or the arrow with the square. So I guess it's not called?&lt;/P&gt;&lt;P&gt;thanks for the hint with the MouseMove, but I don't get what exactly should I do with that?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Sep 2023 06:52:48 GMT</pubDate>
    <dc:creator>nadja</dc:creator>
    <dc:date>2023-09-07T06:52:48Z</dc:date>
    <item>
      <title>Dockpane with listed files: drag&amp;drop method to add files to map does not work. where's the issue?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/dockpane-with-listed-files-drag-amp-drop-method-to/m-p/1326233#M12088</link>
      <description>&lt;P&gt;Hi - I'm new to this SDK and C#. I'm trying to code a dockpane which lists all rasters of a given folder. this works. now I would like to add the listed rasters with drag&amp;amp;drop (or right-click - add) to the current map. unfortunately I don't get it to work. it doesn't throw any errors, so I have no clue what's missing... can someone help me please?&lt;/P&gt;&lt;P&gt;here my xaml:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        &amp;lt;ListView Name="FileListView" SelectionChanged="FileListView_SelectionChanged"  AllowDrop="True" Drop="FileListView_Drop" Height="Auto" Margin="0,28,0,113" Grid.Row="1"&amp;gt;
            &amp;lt;ListView.View&amp;gt;
                &amp;lt;GridView&amp;gt;
                    &amp;lt;GridViewColumn Header="Filename" Width="250"&amp;gt;
                        &amp;lt;GridViewColumn.CellTemplate&amp;gt;
                            &amp;lt;DataTemplate&amp;gt;
                                &amp;lt;TextBlock Text="{Binding}" /&amp;gt;
                            &amp;lt;/DataTemplate&amp;gt;
                        &amp;lt;/GridViewColumn.CellTemplate&amp;gt;
                    &amp;lt;/GridViewColumn&amp;gt;
                &amp;lt;/GridView&amp;gt;
            &amp;lt;/ListView.View&amp;gt;
        &amp;lt;/ListView&amp;gt;
        &amp;lt;Button Content="Refresh" Click="OnRefreshButtonClicked" HorizontalAlignment="Left" Margin="0,3,0,0" Grid.Row="1" VerticalAlignment="Top"/&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here my xaml.cs:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.IO;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;


namespace dockpane_parcs
{
    /// &amp;lt;summary&amp;gt;
    /// Interaction logic for Dockpane1View.xaml
    /// &amp;lt;/summary&amp;gt;
    public partial class Dockpane1View : UserControl
    {

        private ObservableCollection&amp;lt;string&amp;gt; fileNames;

        public Dockpane1View()
        {
            InitializeComponent();

            fileNames = new ObservableCollection&amp;lt;string&amp;gt;();
            FileListView.ItemsSource = fileNames;

            FileListView.Drop += FileListView_Drop;
        }

        private void OnRefreshButtonClicked(object sender, RoutedEventArgs e)
        {
            // Define the list of allowed file extensions
            string[] allowedExtensions = { ".tif", ".TIF", ".tiff", ".TIFF" };

            // Update the list of files in a folder
            string folderPath = @"C:\XXXX\YYYYY"; // Replace with your folder path

            try
            {

                // Get a list of files with the allowed extensions from the folder
                var files = Directory.GetFiles(folderPath)
                                     .Where(file =&amp;gt; allowedExtensions.Contains(System.IO.Path.GetExtension(file)))
                                     .ToList();

                fileNames.Clear();
                foreach (string file in files)
                {
                    fileNames.Add(System.IO.Path.GetFileName(file));
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error: {ex.Message}");
            }
        }

        private void FileListView_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                // Get the dropped files as an array of strings
                string[] droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop);

                // Filter for allowed file extensions
                string[] allowedExtensions = { ".tif", ".TIF", ".tiff", ".TIFF" };
                var validFiles = droppedFiles.Where(file =&amp;gt; allowedExtensions.Contains(System.IO.Path.GetExtension(file)));

                // Add the valid files to the ObservableCollection
                foreach (string file in validFiles)
                {
                    fileNames.Add(System.IO.Path.GetFileName(file));
                }
            }
        }

        private void FileListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Sep 2023 06:31:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/dockpane-with-listed-files-drag-amp-drop-method-to/m-p/1326233#M12088</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2023-09-07T06:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dockpane with listed files: drag&amp;drop method to add files to map does not work. where's the issue?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/dockpane-with-listed-files-drag-amp-drop-method-to/m-p/1326236#M12089</link>
      <description>&lt;P&gt;Could you be a bit more specific about what exactly does not work? For instance, is the Drop event called at all?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That said, I think you need to initiate drag-drop in the MouseMove event first. See &lt;A href="https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-enabling-drag-and-drop-on-a-user-control?view=netframeworkdesktop-4.8#implement-drag-source-events-in-the-user-control" target="_self"&gt;here&lt;/A&gt; for an example (it is for .NET Framework, but Core will probably be very similar)&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 06:40:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/dockpane-with-listed-files-drag-amp-drop-method-to/m-p/1326236#M12089</guid>
      <dc:creator>BerendVeldkamp</dc:creator>
      <dc:date>2023-09-07T06:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dockpane with listed files: drag&amp;drop method to add files to map does not work. where's the issue?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/dockpane-with-listed-files-drag-amp-drop-method-to/m-p/1326240#M12090</link>
      <description>&lt;P&gt;Thank you for your quick response. Honestly, I'm not sure.&amp;nbsp; I don't see the mouse change from the arrow to the forbidden-sign or the arrow with the square. So I guess it's not called?&lt;/P&gt;&lt;P&gt;thanks for the hint with the MouseMove, but I don't get what exactly should I do with that?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 06:52:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/dockpane-with-listed-files-drag-amp-drop-method-to/m-p/1326240#M12090</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2023-09-07T06:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Dockpane with listed files: drag&amp;drop method to add files to map does not work. where's the issue?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/dockpane-with-listed-files-drag-amp-drop-method-to/m-p/1326241#M12091</link>
      <description>&lt;P&gt;Did you read the article I linked to? It will tell you exactly what to do&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 06:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/dockpane-with-listed-files-drag-amp-drop-method-to/m-p/1326241#M12091</guid>
      <dc:creator>BerendVeldkamp</dc:creator>
      <dc:date>2023-09-07T06:56:36Z</dc:date>
    </item>
  </channel>
</rss>

