1

我有一个集合说它NotificationHistoryCollection是一个NotificationHistory对象的集合,它又具有NotificationDetails对象和集合NotificationHistoryDetail。如何在 silverlight 4.0 中绑定NotificationDetails到数据网格并将集合绑定到另一个数据网格NotificationHistoryDetail

4

1 回答 1

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>

结果: 在此处输入图像描述

于 2012-10-19T08:06:01.893 回答