When my App starts, it connects automatically to our PI System, and then because we set the DatabasePicker.SystemPicker to the ServerPicker, it automatically triggers the DatabasePicker_SelectionChange event. This appears to load whatever database I've been using.
I want to automatically look for the Weather database (which I've named Weather_TRAINING). To do this, I figured I'd hook into the ServerPicker_ConnectionChange event, and then set the desired database. I've had two problems with this:
1.) The "Set" doesn't appear to do anything for DataBaseSelector.AFDatabase
private void ServerSelector_ConnectionChange(object sender, OSIsoft.AF.UI.SelectionChangeEventArgs e)
if (ServerSelector.PISystem == null) return;
//Set to the preferred Default database.
DataBaseSelector.AFDatabase = ServerSelector.PISystem.Databases[DefaultDataBaseName];
On line 9 above, it triggers the "DataBaseSelector_SelectionChange" event, but the "AFDataBase" property is Null at this time. Trying the "InitialSelection" field doesn't work either.
2.) Once loaded, the DataBaseSelector SelectionChange event fires again, and sets the database to the "normal" default.
In short: How do I use the AFDatabasePicker in conjunction with the PISystemPicker to set the default database?