Last active
August 29, 2015 14:17
-
-
Save sakapon/88eb8440a779be13e896 to your computer and use it in GitHub Desktop.
WpfSample / LayoutWpf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace LayoutWpf | |
{ | |
public class AppModel | |
{ | |
public int[] Numbers { get; private set; } | |
public AppModel() | |
{ | |
Numbers = Enumerable.Range(1, 15).ToArray(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:local="clr-namespace:LayoutWpf" x:Class="LayoutWpf.MainWindow" | |
Title="MainWindow" Width="900" Height="600" FontSize="32"> | |
<Window.Resources> | |
<ItemsPanelTemplate x:Key="NumbersPanelTemplate"> | |
<WrapPanel IsItemsHost="True"/> | |
</ItemsPanelTemplate> | |
<DataTemplate x:Key="NumberDataTemplate"> | |
<TextBlock Text="{Binding Mode=OneWay, StringFormat=No.\{0\}}" Width="120" TextAlignment="Center"/> | |
</DataTemplate> | |
</Window.Resources> | |
<Window.DataContext> | |
<local:AppModel/> | |
</Window.DataContext> | |
<Grid> | |
<Grid.ColumnDefinitions> | |
<ColumnDefinition/> | |
<ColumnDefinition/> | |
</Grid.ColumnDefinitions> | |
<Grid.RowDefinitions> | |
<RowDefinition/> | |
<RowDefinition/> | |
</Grid.RowDefinitions> | |
<Grid Margin="20" Background="#FFEECCBB"> | |
<ItemsControl ItemsSource="{Binding Numbers}" ItemsPanel="{DynamicResource NumbersPanelTemplate}" ItemTemplate="{DynamicResource NumberDataTemplate}"/> | |
</Grid> | |
<ScrollViewer Grid.Column="1" Margin="20" Background="#FFCCEEBB"> | |
<ItemsControl ItemsSource="{Binding Numbers}" ItemsPanel="{DynamicResource NumbersPanelTemplate}" ItemTemplate="{DynamicResource NumberDataTemplate}"/> | |
</ScrollViewer> | |
<Viewbox Grid.Row="1" Margin="20"> | |
<Grid Width="390" Height="260" Background="#FFBBCCEE"> | |
<ItemsControl ItemsSource="{Binding Numbers}" ItemsPanel="{DynamicResource NumbersPanelTemplate}" ItemTemplate="{DynamicResource NumberDataTemplate}"/> | |
</Grid> | |
</Viewbox> | |
<Grid Grid.Row="1" Grid.Column="1" Margin="20" Background="#FFFFEEBB"> | |
<Viewbox MaxWidth="360" HorizontalAlignment="Left" VerticalAlignment="Top"> | |
<Grid Width="360" Background="LightGray"> | |
<ItemsControl ItemsSource="{Binding Numbers}" ItemsPanel="{DynamicResource NumbersPanelTemplate}" ItemTemplate="{DynamicResource NumberDataTemplate}"/> | |
</Grid> | |
</Viewbox> | |
</Grid> | |
</Grid> | |
</Window> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment