'How to close ComboBox list items when moving application window of my WinRT/C++ UWP application?

I have a pair of ComboBox controls having IsEditable() true as well as false.

When I am scrolling through my application or moving my application window (by clicking on the title bar) with list popup open, I would like to close the ComboBox list popup as otherwise there would be a weird delay in aligning the list correctly below the control.

Is this possible in UWP with WinRT/C++? If so, kindly suggest how to.

I did an investigation to find if any events are there to handle in such a scenario when ComboBox control is essentially displaced from initial position while moving the app window/scrolling the app, but couldn't find any help.

Edit: Adding ComboBox image from XAML Controls Gallery to demonstrate the behaviour. In case if IsEditable set as true, when popup is opened and application is scrolled then popup goes outside the window. Instead I would like to dismiss the popup itself. However, if IsEditable is set as false then we cannot scroll until the popup is dismissed.

enter image description here

Update: The code I tested for PointerWheelChanged

void CBFile2022X::OnPointerWheelChangedHandler( Windows::Foundation::IInspectable const& sender,
                                               Windows::UI::Xaml::Input::PointerRoutedEventArgs const& eventargs )
    {
         OutputDebugString( L"PointerWheelChanged" );

         if( ComboBox != nullptr )
         {
             ComboBox.IsEnabled( false );
             ComboBox.IsEnabled( true );
         }
    }


Solution 1:[1]

I have to say that currently there is no event to detect if the application window is moved or changed its location.

Update:

You could handle the UIElement.PointerWheelChanged Event which will be fired when users scroll the mouse wheel. You could set the IsEnabled property of the ComboBox to false first and then set it to true, this will make the ComboBox lose its focus. Like:

   private void Mypanel_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
    {
        FontsCombo.IsEnabled = false;
        FontsCombo.IsEnabled = true;
    }

Update2:

If you are using a ScrollViewer you could try to handle the ScrollViewer.ViewChanging Event.

  private void ScrollViewer_ViewChanging(object sender, ScrollViewerViewChangingEventArgs e)
    {
        FontsCombo.IsEnabled = false;
        FontsCombo.IsEnabled = true;
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1