我有两个数组:
$anna_array = array("soccer" => "10", "basketball" => "20", "tennis" => "30", "atletics" => "40", "volleyball" => "50");
$john_array = array("soccer" => "15", "basketball" => "15", "atletics" => "45");
解释
安娜在足球比赛得分为10分,约翰比分为15分,依此类推。
我想在两个数组中返回相同的活动。类似的东西:
安娜活动:足球= 10 - 篮球= 20 - Atletics = 40。
John活动:Soccer = 15 - Basketball = 15 - Atletics = 45.
任何人都可以帮我吗?
答案 0 :(得分:1)
您可以使用<Grid>
<DataGrid x:Name="DGOrders" Margin="30" AutoGenerateColumns="False" ItemsSource="{Binding OrdersCollection}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding OrderId}" Header="Order ID" />
<DataGridTemplateColumn Header="User" Width="200" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox SelectedValue="{Binding SelectedUserId}" SelectedValuePath="UserId" DisplayMemberPath="CompanyName" HorizontalContentAlignment="Stretch" ItemsSource="{Binding DataContext.UsersCollection,ElementName=DGOrders}" >
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Margin="5" Grid.Column="0" Text="{Binding UserId}"/>
<TextBlock Margin="5" Grid.Column="1" Text="{Binding CompanyName}"/>
<TextBlock Margin="5" Grid.Column="2" Text="{Binding UserName}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
计算数组的交集。
array_intersect_key