Force WinRT app to snapped view

隐身守侯 提交于 2019-12-18 09:41:15

问题


For one of my apps I'd like to send the app to snapped view after tapping a button. As far as I know there's no public API available to send a running application to snapped view. Did anyone find a workaround to do this?

Somehow it should be possible since you're able to do it in Windows 8 itself, and snap one of the running apps.

Update: Being able to trigger a Win+. might do the same trick, but the SendKeys API isn't available in WinRT either.


回答1:


Windows 10 has a ApplicationView.TryResizeView method

So... to summarize the interesting WinRT journey:

Windows 8

Has a a 'Snapped' mode that a only a user can initiate. the developer can try to unsnap with the TryUnsnap method

Windows 8.1

Does not have Snapped mode, and TryUnsnap is deprecated. The dev can still listen for window size changes and know if the app view is in a smaller size as before.

Windows 10

Introduced the ApplicationView.TryResizeView method, where the dev can try to resize. Window size changed event is still there.

ApplicationView.GetForCurrentView().TryResizeView(new size(width, height)));



回答2:


There is no way to force an application into snapped mode - it has to be a user initiated action.

An application can request to be unsnapped through:

Windows.UI.ViewManagement.ApplicationView.TryUnsnap();

Which tries to push the app into fill mode.



来源:https://stackoverflow.com/questions/11907058/force-winrt-app-to-snapped-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!