windows 10 自适应布局

https://msdn.microsoft.com/library/windows/apps/dn894631.aspx

Use visual state triggers to build UI that can adapt to available screen space

Your UI may need to adapt to changes in window size. Adaptive visual states allows you to change the visual state in response to changes in the size of the window.

StateTriggers define a threshold at which a visual state is activated, which then sets layout properties as appropriate for the window size that triggered the state change.

In the following example, when the window size is 720 pixels or more in width the best-rated games are displayed to the right of the top free games panel and aligned with the top of the top free games panel. The visual state named wideView is triggered when the window is a minimum of 720 pixels wide, which then arranges the Best-rated games panel to appear to the right of, and aligned with the top of, the Top free games panel.

When the window is less than 720 pixels, the narrowView visual state is triggered because the wideViewtrigger is no longer satisfied and so no longer in effect. The narrowView visual state positions the Best-rated games panel below, and aligned with the left of, the Top paid games panel:

Here is the XAML for the visual state triggers described above. The definition of the panels, alluded to by "..." below, has been removed for brevity.

XAML

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup>
            <VisualState x:Name="wideView">
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="720" />
                </VisualState.StateTriggers>
                <VisualState.Setters>
                    <Setter Target="best.(RelativePanel.RightOf)" Value="free"/>
                    <Setter Target="best.(RelativePanel.AlignTopWidth)" Value="free"/>
                </VisualState.Setters>
            </VisualState>
            <VisualState x:Name="narrowView">
                <VisualState.Setters>
                    <Setter Target="best.(RelativePanel.Below)" Value="paid"/>
                    <Setter Target="best.(RelativePanel.AlignLeftWithPanel)" Value="true"/>
                </VisualState.Setters>
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="0" />
                </VisualState.StateTriggers>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    ...
</Grid>
时间: 2024-11-10 00:14:54

windows 10 自适应布局的相关文章

【WinHec启发录】透过Windows 10技术布局,谈微软王者归来

每一个时代都有王者,王者的成功,往往是由于恰逢其时地公布了一个成功的产品(具有里程碑意义,划时代的产品).Windows 95的成功标示着微软是PC时代的王者:WinXP的成功标示着微软是互联网时代的王者.而恰恰是Windows Vista.Windows 7和Windows 8对移动互联网时代的忽视,王者地位拱手让人.在即将来临的物联网时代,Windows 10的即将成功,预示着微软将成为物联网时代的王者. 物联网的三要素,无非是云.入口.端. 而微软恰恰在这三点上,都已经完毕了最重要的布局.

【WinHec启示录】透过Windows 10技术布局,谈微软王者归来

每个时代都有王者,王者的成功,往往是因为恰逢其时地发布了一个成功的产品(具有里程碑意义,划时代的产品).Windows 95的成功标示着微软是PC时代的王者:WinXP的成功标示着微软是互联网时代的王者:而恰恰是Windows Vista.Windows 7和Windows 8对移动互联网时代的忽视,王者地位拱手让人:在即将来临的物联网时代,Windows 10的即将成功,预示着微软将成为物联网时代的王者. 物联网的三要素,无非是云.入口.端.而微软恰恰在这三点上,都已经完成了最重要的布局. 一

[深入浅出Windows 10]布局原理

5.2 布局原理 很多时候在编写程序界面的时候都会忽略了应用布局的重要性,仅仅只是把布局看作是对UI元素的排列,只要能实现布局的效果就可以了,但是在实际的产品开发中这是远远不够的,你可能面临要实现的布局效果要比常规布局更加复杂,这就需要对布局的技术知识有深入的理解和掌握才能够实现.要实现一个布局的效果,可能会有很多总布局方案,我们该怎么去选择实现的方法?如果要实现的一个布局效果是比较复杂的,我们该怎么去对这种布局规律进行封装?要解决这些问题,首要的问题就是需要我们对程序的布局原理有着深入的理解.

背水一战 Windows 10 (54) - 控件(集合类): ItemsControl 的布局控件 - OrientedVirtualizingPanel, VirtualizingStackPanel, WrapGrid

[源码下载] 作者:webabcd 介绍背水一战 Windows 10 之 控件(集合类 - ItemsControl 的布局控件) OrientedVirtualizingPanel VirtualizingStackPanel WrapGrid 示例1.OrientedVirtualizingPanel(基类) 的示例Controls/CollectionControl/ItemsControlDemo/LayoutControl/OrientedVirtualizingPanelDemo.

背水一战 Windows 10 (38) - 控件(布局类): Panel, Canvas, RelativePanel, StackPanel, Grid

原文:背水一战 Windows 10 (38) - 控件(布局类): Panel, Canvas, RelativePanel, StackPanel, Grid [源码下载] 作者:webabcd 介绍背水一战 Windows 10 之 控件(布局类) Panel Canvas RelativePanel StackPanel Grid 示例1.Panel(基类) 的示例Controls/LayoutControl/PanelDemo.xaml <Page x:Class="Window

背水一战 Windows 10 (39) - 控件(布局类): VariableSizedWrapGrid, Border, Viewbox, SplitView

原文:背水一战 Windows 10 (39) - 控件(布局类): VariableSizedWrapGrid, Border, Viewbox, SplitView [源码下载] 作者:webabcd 介绍背水一战 Windows 10 之 控件(布局类) VariableSizedWrapGrid Border Viewbox SplitView 示例1.VariableSizedWrapGrid 的示例Controls/LayoutControl/VariableSizedWrapGri

背水一战 Windows 10 (53) - 控件(集合类): ItemsControl 的布局控件 - ItemsStackPanel, ItemsWrapGrid

[源码下载] 作者:webabcd 介绍背水一战 Windows 10 之 控件(集合类 - ItemsControl 的布局控件) ItemsStackPanel ItemsWrapGrid 示例1.ItemsStackPanel 的示例Controls/CollectionControl/ItemsControlDemo/LayoutControl/ItemsStackPanelDemo.xaml <Page x:Class="Windows10.Controls.Collection

响应式布局和自适应布局的不同

学了前端一段时间了,发现大家都搅浑了自适应布局和响应式布局的差别.现在我来和大家说下它们的不同: 自适应的体验   http://m.ctrip.com/html5/响应式的体验   http://segmentfault.com/ 整理了自己查阅的知识点,给各位一些提示. 起初,网页设计者都会涉及固定宽度的页面,最开始的电脑显示器分辨率种类不多,因为当时本来电脑就少,即使有变化也是800,850,870,880,比如开源中国的网页就是固定宽度为998来定制的,至于为啥是998,我也不知道...

rem自适应布局的回顾总结

使用rem实现自适应布局,应该算是当前移动前端的一大趋势,有些人对此还有点迷惑,搞不懂rem是如何实现自适应布局,如何根据设计稿来调整rem的值?rem布局如何用雪碧背景图片?rem一定要加载JS吗?rem的根html font-size设置为多少合适?看看这篇文章,也许能帮到你. 这些问题整理来自之前发表过的文章,细心的读者也可以自己翻翻之前的内容找到答案,本文统一给个回复,如果对你有用,还请点个赞,谢谢! rem自适应原理 rem是根据html的font-size大小来变化,正是基于这个出发