示例#1
0
        private void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            // Do not load your data at design time.
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                // Pretend we are in the EAC
                using (StreamReader reader = new StreamReader(@"Test Data\TestWindowConsoleParameter.xml"))
                {
                    ConfigData.RawXML = reader.ReadToEnd();
                }

                //Load your data here and assign the result to the CollectionViewSource.
                System.Windows.Data.CollectionViewSource myCollectionViewSource = (System.Windows.Data.CollectionViewSource) this.Resources["serversViewSource"];
                //myCollectionViewSource.Source = Common.ApplicationDataSet.Servers;

                Data.ApplicationDataSetTableAdapters.ServersTableAdapter   serversTableAdapter;
                Data.ApplicationDataSetTableAdapters.InstancesTableAdapter instancesTableAdapter;
                Data.ApplicationDataSetTableAdapters.DatabasesTableAdapter databasesTableAdapter;

                Data.ApplicationDataSetTableAdapters.TableAdapterManager tableAdapterManager;

                serversTableAdapter   = new Data.ApplicationDataSetTableAdapters.ServersTableAdapter();
                instancesTableAdapter = new Data.ApplicationDataSetTableAdapters.InstancesTableAdapter();
                databasesTableAdapter = new Data.ApplicationDataSetTableAdapters.DatabasesTableAdapter();

                tableAdapterManager = new Data.ApplicationDataSetTableAdapters.TableAdapterManager();

                // Must have to do more work before can do this.  Connection is null
                //tableAdapterManager.Connection.ConnectionString = ConfigData.SQLMonitorDBConnection;\

                // DO this instead for now.
                serversTableAdapter.Connection.ConnectionString   = ConfigData.SQLMonitorDBConnection;
                instancesTableAdapter.Connection.ConnectionString = ConfigData.SQLMonitorDBConnection;
                databasesTableAdapter.Connection.ConnectionString = ConfigData.SQLMonitorDBConnection;

                try
                {
                    //serversTableAdapter.Fill(Common.ApplicationDataSet.Servers);
                    //instancesTableAdapter.Fill(Common.ApplicationDataSet.Instances);
                    //databasesTableAdapter.Fill(Common.ApplicationDataSet.Databases);
                    //serversListView.ItemsSource = Common.ApplicationDataSet.Servers;
                    //serversBindingSource.DataSource = Common.ApplicationDS.Servers;
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(text: "Initial Load Error: " + ex.ToString(), caption: "Error", buttons: System.Windows.Forms.MessageBoxButtons.OK);
                }

                //serversDataGrid.DataContext = Common.ApplicationDataSet.Servers.DefaultView;
                // This is needed to make it work.
                //ServerList.DataContext = Common.ApplicationDataSet.Servers.DefaultView;
            }

            masterListManager.Load();
        }
        private void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            // Do not load your data at design time.
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                CollectionViewSource serversViewSource = ((CollectionViewSource)(this.FindResource("serversViewSource")));
                serversViewSource.Source = Common.ApplicationDataSet.Servers;
            }

            masterListManager.Load();
        }