zoukankan      html  css  js  c++  java
  • uwp通用应用布局触发器AdaptiveTrigger

    MainPage.xaml

    <Page
        x:Class="App1.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:App1"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    
        <Page.Resources>
            <DataTemplate x:Key="dt1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Rectangle Fill="Red" Width="30" Height="30" Margin="6,4"/>
                    <TextBlock Grid.Column="1" FontSize="18" Text="{Binding}"/>
                </Grid>
            </DataTemplate>
            <DataTemplate x:Key="dt2">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <Rectangle Fill="Red" Width="120" Height="120" Margin="5"/>
                    <TextBlock Grid.Row="1" Margin="2" Text="{Binding}"/>
                </Grid>
            </DataTemplate>
            <ItemsPanelTemplate x:Key="ip1">
                <ItemsStackPanel Orientation="Vertical"/>
            </ItemsPanelTemplate>
            <ItemsPanelTemplate x:Key="ip2">
                <ItemsWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="3"/>
            </ItemsPanelTemplate>
        </Page.Resources>
    
        <Grid>
            <ListView Name="lv" ItemTemplate="{StaticResource dt1}" ItemsPanel="{StaticResource ip1}">
                <x:String>item 1</x:String>
                <x:String>item 2</x:String>
                <x:String>item 3</x:String>
                <x:String>item 4</x:String>
                <x:String>item 5</x:String>
                <x:String>item 6</x:String>
            </ListView>
    
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup>
                    <VisualState>
                        <VisualState.StateTriggers>
                            <AdaptiveTrigger MinWindowWidth="600"/>
                        </VisualState.StateTriggers>
                        <VisualState.Setters>
                            <Setter Target="lv.ItemTemplate" Value="{StaticResource dt2}"/>
                            <Setter Target="lv.ItemsPanel" Value="{StaticResource ip2}"/>
                        </VisualState.Setters>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
        </Grid>
    </Page>
  • 相关阅读:
    Aseprite+Cocos:打包像素画图,导入到cocos里并动起来
    自定义博客园个人皮肤
    埃航和737MAX坠毁:软件优先级问题
    淘宝网——软件质量属性场景分析
    王概凯《架构漫谈》阅读笔记
    2965 -- The Pilots Brothers' refrigerator
    UVa10082 -- WERTYU
    1753 -- Flip Game
    1083 -- Moving Tables
    2159 -- Ancient Cipher
  • 原文地址:https://www.cnblogs.com/maoriaty/p/9065235.html
Copyright © 2011-2022 走看看