DataContextDataContext context1 = new DataContextDataContext();
public MainWindow()
{
InitializeComponent();
DataContext = new ObservableCollection<MyObject>();
RadGridView1.Filtered+=new EventHandler<GridViewFilteredEventArgs>(RadGridView1_Filtered);
ObservableCollection<MyObject> _MyObject = new ObservableCollection<MyObject>();
foreach (var p in context1.Students)
{
_MyObject.Add(new MyObject { ID = p.StudentID, Name = p.StudentFN });
}
}
void RadGridView1_Filtered(object sender, GridViewFilteredEventArgs e)
{
RadGridView1.ItemsSource = ObservableCollection<MyObject>();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
}
}
public class MyObject
{
public int ID { get; set; }
public string Name { get; set; }
}
如何将我的 ObservableCollections 绑定(bind)到 ItemsSource?
最佳答案
您想将 ItemSource
设置为您在构造函数中创建的 ObservableCollection
的实例:
RadGridView1.ItemsSource = _MyObject;
关于c# - 如何将 ObservableCollections 绑定(bind)到 ItemsSource?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4303557/