Can only click GalleryItem once - Pro SDK

961
5
Jump to solution
05-02-2019 10:27 AM
TimWhiteaker
Occasional Contributor II

In ArcGIS Pro, I can only click a particular item from my custom gallery once.  If I click the gallery drop down and click the same item again, nothing happens.  Here's the OnClick:

protected override void OnClick(GalleryItem item)
{
 ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(item.Text);
 base.OnClick(item);
}

I put a breakpoint in the code on the message box line, and it hits it the first time I click an item but not the second.  However, if I click a different gallery item, then the breakpoint is hit (but not if I click that second gallery item again).

When I compile the gallery sample, I get the same behavior.  To reproduce the bug:

1. Download and build the gallery sample (under Framework/Gallery).

2. Start Pro and click a web map from the gallery. It is added to your project.

3. Delete the map and click the same web map in the gallery again. No map is added this time.

What's the trick to handling when a user clicks on a gallery item they've clicked before?

Environment:

Windows 10

Visual Studio 2017 Community Edition

Pro SDK for .NET (and Utilities) 2.3.0.15769

Pro 2.3.2

0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

Hi Tim

Set the AllywaysFireOnClick property on the Gallery class to true. This will allow you to click the selected item in a gallery.

I will update the Gallery wiki page with this info.

Thanks

Uma

View solution in original post

5 Replies
UmaHarano
Esri Regular Contributor

Hi Tim,

I see this issue too using the sample. We will investigate this behavior. Thank you for reporting this!

Uma

0 Kudos
UmaHarano
Esri Regular Contributor

Hi Tim

Set the AllywaysFireOnClick property on the Gallery class to true. This will allow you to click the selected item in a gallery.

I will update the Gallery wiki page with this info.

Thanks

Uma

StefanDieters1
New Contributor III

Hi Uma,

I have this problem also with the Galley. I have followed your link to AlwaysFireOnClick . This is under the ArcPro SDK 2.3. Browsing up to the GalleryClass ArcGIS Pro 2.3 API Reference Guide , AlwaysFireOnClick is not listed in the DAML Attributes. It is a property like loadingMessage. I can set a loadingMessage within the Gallery block in the Config.daml, however I cannot use alwaysFireOnclick. Intllesense returns "alwaysFireOnClick attribute not declared.

I have tried various capitalization's  for AlwaysFireOnClick

How do you use this property?

I am using:

Visual Studio 2017 Community

ArcPro SDK 2.3.0.15769

coding for ArcGIS Pro 2.3.0

Stefan

0 Kudos
TimWhiteaker
Occasional Contributor II

I put it in the .cs file for the gallery.

        private bool _isInitialized;
        protected override void OnDropDownOpened()
        {
            Initialize();
        }
        private void Initialize()
        {
            if (_isInitialized)
                return;
            // Code to add your gallery items...
            // Items added. Now wrap up.
            AlwaysFireOnClick = true;  // Required so you can click a gallery item again that you had clicked last time
            _isInitialized = true;
        }
StefanDieters1
New Contributor III

That's it. Works.

Thanks

0 Kudos