WPF ListBox的DataTemplate例子

 

 1 <ListBox Name="lbLogInfo">

 2     <ListBox.ItemTemplate>

 3         <DataTemplate>

 4             <Grid Margin="2">

 5                 <Grid.RowDefinitions>

 6                     <RowDefinition/>

 7                     <RowDefinition/>

 8                 </Grid.RowDefinitions>

 9                 <Grid.ColumnDefinitions>

10                     <ColumnDefinition/>

11                     <ColumnDefinition/>

12                 </Grid.ColumnDefinitions>

13                 <TextBlock Grid.RowSpan="2" MinWidth="80" Text="{Binding Path=State,

14                      Converter={StaticResource DisplayConverter}}"/>

15                 <TextBlock Grid.Column="1" Text="{Binding Path=FileName}"/>

16                 <TextBlock Grid.Row="1" Grid.Column="1" Margin="0,2" Text="{Binding Path=ModifiedDate}"/>

17             </Grid>

18         </DataTemplate>

19     </ListBox.ItemTemplate>

20 </ListBox>
View Code

 

你可能感兴趣的:(template)