1
我有一個集合,說NotificationHistoryCollection
這是一個NotificationHistory
對象的集合,它的對象又有NotificationDetails
對象和集合NotificationHistoryDetail
。如何在Silverlight 4.0將datagrid綁定到silverlight中的自定義對象的集合4
我有一個集合,說NotificationHistoryCollection
這是一個NotificationHistory
對象的集合,它的對象又有NotificationDetails
對象和集合NotificationHistoryDetail
。如何在Silverlight 4.0將datagrid綁定到silverlight中的自定義對象的集合4
綁定NotificationDetails
到DataGrid和NotificationHistoryDetail
收集到另一個數據網格這應該給你一些想法:
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
friends.Add(new Friend(){Name = "Pappu",Email = new EmailAddress(){Email = "[email protected]"}});
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>
結果: