瀏覽代碼

improve items repeater page.

Dan Walmsley 5 年之前
父節點
當前提交
03ec99c048

+ 11 - 2
samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml

@@ -12,6 +12,8 @@
         <ComboBoxItem>Stack - Horizontal</ComboBoxItem>
         <ComboBoxItem>UniformGrid - Vertical</ComboBoxItem>
         <ComboBoxItem>UniformGrid - Horizontal</ComboBoxItem>
+        <ComboBoxItem>WrapLayout - Horizontal</ComboBoxItem>
+        <ComboBoxItem>WrapLayout - Veritcal</ComboBoxItem>
       </ComboBox>
       <Button Command="{Binding AddItem}">Add Item</Button>
       <Button Command="{Binding RandomizeHeights}">Randomize Heights</Button>
@@ -22,9 +24,16 @@
                     HorizontalScrollBarVisibility="Auto"
                     VerticalScrollBarVisibility="Auto">
         <ItemsRepeater Name="repeater" Background="Transparent" Items="{Binding Items}">
+          <ItemsRepeater.Styles>
+            <Style Selector="Border:pointerover">
+              <Setter Property="Width" Value="200" />
+            </Style>
+          </ItemsRepeater.Styles>
           <ItemsRepeater.ItemTemplate>
-            <DataTemplate>
-              <TextBlock Focusable="True" Height="{Binding Height}" Text="{Binding Text}"/>
+            <DataTemplate>              
+              <Border Background="Purple" BorderThickness="2" BorderBrush="Green" MinHeight="100" MinWidth="100">
+                <TextBlock Focusable="True" Height="{Binding Height}" Text="{Binding Text}"  Foreground="White" />
+              </Border>              
             </DataTemplate>
           </ItemsRepeater.ItemTemplate>
         </ItemsRepeater>

+ 20 - 0
samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs

@@ -70,6 +70,26 @@ namespace ControlCatalog.Pages
                         MinItemHeight = 200,
                     };
                     break;
+                case 4:
+                    _scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
+                    _scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
+                    _repeater.Layout = new WrapLayout
+                    {
+                        Orientation = Orientation.Vertical,
+                        HorizontalSpacing = 20,
+                        VerticalSpacing = 20
+                    };
+                    break;
+                case 5:
+                    _scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
+                    _scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
+                    _repeater.Layout = new WrapLayout
+                    {
+                        Orientation = Orientation.Horizontal,
+                        HorizontalSpacing = 20,
+                        VerticalSpacing = 20
+                    };
+                    break;
             }
         }