我有一个集合说NotificationHistoryCollection
,它是NotificationHistory
个对象的集合,而NotificationDetails
个对象又有NotificationHistoryDetail
个对象和NotificationDetails
的集合。如何将NotificationHistoryDetail
绑定到数据网格和{{1}}集合到Silverlight 4.0中的另一个数据网格
答案 0 :(得分:0)
这应该会给你一些想法:
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
friends.Add(new Friend(){Name = "Pappu",Email = new EmailAddress(){Email = "test@test.com"}});
dgFriends.ItemsSource = Friends;
}
ObservableCollection<Friend> friends = new ObservableCollection<Friend>();
public ObservableCollection<Friend> Friends { get { return friends; } set { friends = value; } }
}
public class Friend
{
public string Name { get; set; }
public string LastName { get; set; }
public EmailAddress Email { get; set; }
}
public class EmailAddress
{
public string Email { get; set; }
}
<data:DataGrid x:Name="dgFriends" AutoGenerateColumns="False">
<data:DataGrid.Columns>
<data:DataGridTextColumn Binding="{Binding Email.Email}" Header="EmailAddress" IsReadOnly="True"></data:DataGridTextColumn>
</data:DataGrid.Columns>
</data:DataGrid>
结果: