Listbox横向显示和dataTemplate

来源:互联网 发布:淘宝旺旺网页版 编辑:程序博客网 时间:2024/05/15 00:28
<Window x:Class="PhotoData.AddPhotosWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="AddPhotosWindow" Height="600" Width="800">    <Grid>        <Grid.RowDefinitions>            <RowDefinition Height="26"/>            <RowDefinition/>            <RowDefinition Height="26"/>        </Grid.RowDefinitions>        <Button Content="批量添加照片" Width="100" HorizontalAlignment="Left" Margin="5,2"                Click="AddPhotoes"/>        <ListBox Grid.Row="1" ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">            <ListBox.ItemsPanel>                <ItemsPanelTemplate>                    <WrapPanel IsItemsHost="True"/>                </ItemsPanelTemplate>            </ListBox.ItemsPanel>            <ListBox.ItemTemplate>                <HierarchicalDataTemplate>                    <Grid Margin="5">                        <Grid.RowDefinitions>                            <RowDefinition/>                            <RowDefinition Height="26"/>                        </Grid.RowDefinitions>                        <Image Stretch="Fill" Width="100" Height="100" Source="{Binding ImageSourcePath}"/>                        <TextBlock Grid.Row="1" HorizontalAlignment="Center" Text="{Binding PhotoName}"/>                    </Grid>                </HierarchicalDataTemplate>            </ListBox.ItemTemplate>        </ListBox>        <Button Grid.Row="2" HorizontalAlignment="Right" Margin="5,2" Height="22" Width="60" Content="保存"                Click="SavePhotos"/>    </Grid></Window>

0 0
原创粉丝点击