public MainWindow_Lab() { AirEntities dbContext = new AirEntities(); InitializeComponent(); MetroDataGrid.ItemsSource = dbContext.Members.ToList(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { AirEntities air = new AirEntities(); System.Windows.Data.CollectionViewSource memberViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("memberViewSource"))); // 透過設定 CollectionViewSource.Source 屬性載入資料: memberViewSource.Source = air.Members.ToList(); }