首页 新闻 会员 周边

如何在VisualState.Setter中更改GridView.ItemsPanel属性

0
悬赏园豆:5 [已关闭问题] 关闭于 2015-08-14 17:03

开发Win10 Universal时,使用GridView作为数据容器,我想要在宽屏设备商使用ItemsWarpGrid作为ItemsPanel,而在窄屏设备上使用ItemsStackPanel作为ItemsPanel。我已经添加响应窗口大小的VisualState。请问,

如何在VisualState.Setter中更改GridView.ItemsPanel属性。应该怎么写?

现在这个样子的代码不行。代码如下:

<VisualState x:Name="narrowView">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="{StaticResource MinWindowWidthOfNarrow}"/>
                    </VisualState.StateTriggers>
                    <Setter Target="GridViewLearningRecord.ItemsPanel" Value="ItemsStackPanel"/>
                    </VisualState.Setters>
 </VisualState>
Sago的主页 Sago | 初学一级 | 园豆:48
提问于:2015-08-14 16:29
< >
分享
所有回答(2)
0

不直接点那个空间的属性,在属性里面设置

夜空下的男子 | 园豆:31 (初学一级) | 2015-08-14 16:49

这个写法是可以得。这是Win10新的VisualState写法。

然后,这个问题我自己解决了。

支持(0) 反对(0) Sago | 园豆:48 (初学一级) | 2015-08-14 17:01

@Sago: 嗯,新的东西也要接触

支持(0) 反对(0) 夜空下的男子 | 园豆:31 (初学一级) | 2015-08-14 17:02
0

在资源字典了定义好不同的ItemsPanel.如下

  <ItemsPanelTemplate x:Key="ItemsWrapGrid">
                <ItemsWrapGrid/>
            </ItemsPanelTemplate>
            <ItemsPanelTemplate x:Key="ItemsStackPanel">
                <ItemsStackPanel/>
            </ItemsPanelTemplate>

然后,在VisualState.Setter中绑定上面缩写的静态资源,如下:

 <Setter Target="GridViewLearningRecord.ItemsPanel" Value="{StaticResource ItemsWrapGrid}"/>

 

Sago | 园豆:48 (初学一级) | 2015-08-14 17:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册