110,571
社区成员
发帖
与我相关
我的任务
分享
1 <ItemsControl Grid.Row="1" x:Name="PMItmsControl" VerticalAlignment="Top" ItemsSource="{Binding FirstEntity}">
2 <ItemsControl.ItemsPanel>
3 <ItemsPanelTemplate>
4 <VirtualizingStackPanel Orientation="Vertical"/>
5 </ItemsPanelTemplate>
6 </ItemsControl.ItemsPanel>
7 <ItemsControl.ItemTemplate>
8 <DataTemplate>
9 <Border CornerRadius="5" BorderBrush="YellowGreen" BorderThickness="1" Margin="5">
10 <Grid Width="auto" Height="100" VerticalAlignment="Top">
11 <Grid.RowDefinitions>
12 <RowDefinition/>
13 </Grid.RowDefinitions>
14 <Grid.ColumnDefinitions>
15 <ColumnDefinition Width="60*"/>
16 <ColumnDefinition Width="40*"/>
17 </Grid.ColumnDefinitions>
18 <TextBlock Width="100" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Text="{Binding FirstName}" FontSize="10" >
19 </TextBlock>
20 <ItemsControl ItemsSource="{Binding SecondEntity}" Grid.Column="1" VerticalAlignment="Top">
21 <ItemsControl.ItemsPanel>
22 <ItemsPanelTemplate>
23 <VirtualizingStackPanel Orientation="Vertical"/>
24 </ItemsPanelTemplate>
25 </ItemsControl.ItemsPanel>
26 <ItemsControl.ItemTemplate>
27 <DataTemplate>
28 <Grid>
29 <Grid.ColumnDefinitions>
30 <ColumnDefinition Width="50*"/>
31 <ColumnDefinition Width="50*"/>
32 </Grid.ColumnDefinitions>
33 <TextBlock Text="{Binding SecondName}" Margin="5" Foreground="White" />
34 <TextBlock Grid.Column="1" Text="{Binding Path= DataContext.FirstName, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ItemsControl},AncestorLevel=2}}" Margin="5" Width="40">
35 </TextBlock>
36 </Grid>
37 </DataTemplate>
38 </ItemsControl.ItemTemplate>
39 </ItemsControl>
40 </Grid>
41 </Border>
42 </DataTemplate>
43 </ItemsControl.ItemTemplate>
44 </ItemsControl>
public class FirstEntity
{
public string FirstName { get; set; }
public SecondEntity SecondEntity { get; set; }
}
public class SecondEntity
{
public string SecondName { get; set; }
}
<ItemsControl Grid.Row="1" x:Name="PMItmsControl" VerticalAlignment="Top" ItemsSource="{Binding FirstEntityCollection}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border CornerRadius="5" BorderBrush="YellowGreen" BorderThickness="1" Margin="5">
<Grid Width="auto" Height="100" VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60*"/>
<ColumnDefinition Width="40*"/>
</Grid.ColumnDefinitions>
<TextBlock Width="100" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Text="{Binding FirstName}" FontSize="10" >
</TextBlock>
<ItemsControl ItemsSource="{Binding SecondEntityCollection}" Grid.Column="1" VerticalAlignment="Top">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*"/>
<ColumnDefinition Width="50*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding SecondName}" Margin="5" Foreground="White" />
<TextBlock Grid.Column="1" Text="{Binding Path= DataContext.FirstName, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ItemsControl},AncestorLevel=2}}" Margin="5" Width="40">
</TextBlock>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>