Разработка Java для [закрытой] сети

Словарь ресурсов

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ItemsPanelTemplate x:Key="lstViewItemsPanelTemplate">
        <UniformGrid Columns="3"/>
    </ItemsPanelTemplate>
    <Style TargetType="ListViewItem" x:Key="lstViewItemContainerStyle">
        <Setter Property="HorizontalContentAlignment" 
                Value="Stretch"/>
    </Style>
    <DataTemplate x:Key="lstViewItemTemplate">
        <Grid Width="100"
              Height="100"
              Background="{Binding Color}">
            <StackPanel Margin="10">
                <TextBlock Text="{Binding Title}"/>
                <TextBlock Text="{Binding Description}"/>
            </StackPanel>
        </Grid>
    </DataTemplate>
</ResourceDictionary>

Список представлений

<ListView ItemsPanel="{StaticResource lstViewItemsPanelTemplate}"
          ItemContainerStyle="{StaticResource lstViewItemContainerStyle}"
          ItemTemplate="{StaticResource lstViewItemTemplate}"/>

или

Вы также можете определить глобальный Style в ResourceDictionary.xaml, например,

<Style TargetType="ListView">
    <Setter Property="ItemsPanel" Value="{StaticResource lstViewItemsPanelTemplate}"/>
    <Setter Property="ItemContainerStyle" Value="{StaticResource lstViewItemContainerStyle}"/>
    <Setter Property="ItemTemplate" Value="{StaticResource lstViewItemTemplate}"/>
</Style>
18
задан Tom 2 October 2008 в 13:26
поделиться