从GridView切换到ListView时,Windows Store应用程序的快照
Switching from GridView to ListView when Windows Store app is snapped
我试图改变我的listView控件的布局从"GridView"到" listView "当应用程序被抓拍。当然,它应该在任何其他状态下返回到"GridView"。我写了一些代码,但它不工作,所以我想知道为什么…
这是我写的代码:var viewState = Windows.UI.ViewManagement.ApplicationView;
var list = document.getElementById("messageDisplay").winControl;
if (viewState == Windows.UI.ViewManagement.ApplicationViewState.snapped) {
list.layout = new WinJS.UI.ListLayout();
}
else
{
list.layout = new WinJS.UI.GridLayout();
}
从这里开始,只需监听resize事件并更改listview的布局属性。
我不知道你在代码中什么地方调用了类似的代码,所以这里是你需要的整个方法
<>之前window.addEventListener("大小",函数(e) {var currentViewState = Windows.UI.ViewManagement.ApplicationView.value;var snaps = windows . ui . viewmanagement . applicationviewstate . snaps;if (currentViewState === snap) {that.listView.layout = new WinJS.UI.ListLayout();}else if (lastViewState === snap &¤tViewState == snap) {that.listView.layout = new WinJS.UI.GridLayout();}lastViewState = currentViewState;});尝试调用list.forceLayout(),它救了我很多次命…: -)
相关文章:
- 在Windows 10中自动执行例行程序(主要与浏览器交互)
- Windows形成web浏览器控件和Javascript更改的DOM
- Windows 8固定的网站互动程序
- TypeError:_this.store.getState在使用来自Redux的连接时不是函数
- 如何添加CSS&JavaScript进入Windows窗体应用程序C#.net
- Query JS Ext.data.Store
- 将Windows文件路径组织到文件夹中
- Windows Azure通知中心错误
- Windows Store Cordova App + WinJS:应用在启动时崩溃并出现 JavaScript 运行时
- 如何在Windows Store / WinJS应用程序中处理文件激活
- 记录Windows Store应用程序的选项
- 如何实例化WinMD文件到Windows Store应用程序项目
- 从GridView切换到ListView时,Windows Store应用程序的快照
- 如何实现一个windows store javascript应用的异步for循环
- Windows Store应用程序购买客户信息
- 如何使用空白应用模板在Windows Store应用中进行导航
- Windows Store Bluetooth
- 合并Visual Studio Windows Store App和Windows Phone App解决方案
- 在Windows Store应用程序上执行JavaScript代码
- 为什么不能在Windows Store模板中使用CSS ?