如何在移动 WinRT/C++ 的应用程序窗口时关闭组合框列表项UWP应用程序?

发布于 2025-01-19 02:17:29 字数 1054 浏览 1 评论 0原文

我有一对具有iSedable()为true和false的组合对照。

当我浏览应用程序或使用列表弹出式弹出窗口滚动或移动应用程序窗口(通过单击标题栏)时,我想关闭Combobox列表弹出窗口,否则,将正确对齐该列表在控制下方的列表时会有一个奇怪的延迟。

与WinRT/C ++一起在UWP中可以做到这一点吗?如果是这样,请建议如何做。

我进行了调查,以查找在这种情况下,当Combobox控件基本上从初始位置移动时,在移动应用程序窗口/滚动应用程序时,是否有任何事件要处理,但找不到任何帮助。

编辑:添加来自XAML Controls Gallery的Combobox图像以演示行为。如果可以用作true,则在打开弹出窗口并滚动应用程序时,弹出窗口就会在窗口外面。相反,我想解开弹出窗口本身。但是,如果可用的是错误,则在弹出弹出窗口之前,我们将无法滚动。

更新:我测试了指针的代码

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 );
         }
    }

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 );
         }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

通知家属抬走 2025-01-26 02:17:29

我不得不说,当前没有事件可以检测到应用程序窗口是移动还是更改其位置。

更新:

您可以处理 uielement.pointerwheelchanged事件当用户滚动鼠标车轮时,它将发射。您可以首先将Combobox的属性设置为 false ,然后将其设置为 true ,这将使Combobox失去焦点。喜欢:

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

update2:

如果您使用的是scrollviewer,则可以尝试处理 scrollviewer.viewchanging event

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

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;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文