如何在移动 WinRT/C++ 的应用程序窗口时关闭组合框列表项UWP应用程序?
我有一对具有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.
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不得不说,当前没有事件可以检测到应用程序窗口是移动还是更改其位置。
更新:
您可以处理 uielement.pointerwheelchanged事件当用户滚动鼠标车轮时,它将发射。您可以首先将Combobox的属性设置为 false ,然后将其设置为 true ,这将使Combobox失去焦点。喜欢:
update2:
如果您使用的是
scrollviewer
,则可以尝试处理 scrollviewer.viewchanging event 。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:Update2:
If you are using a
ScrollViewer
you could try to handle the ScrollViewer.ViewChanging Event.