I’ve created a custom UserControl which consists of 12 labels.

Now, when the program loads, the labels with “Default” as the content need to be changed.
// This is called in my main forms constructor, right before InitializeComponent()
public void ShowRigInfo()
{
// This is here because if I try to call PopluateLabels, I get an "Object not
// set to an instance of object" error
grdRigInfo = new RigInfoGrid();
var contractor = SplitString("contractor", _rigInfo);
var projectName = SplitString("projectname", _rigInfo);
var location = SplitString("location", _rigInfo);
var operatorName = SplitString("operator", _rigInfo);
var rigName = SplitString("rigsite_name", _rigInfo);
var rigManager = SplitString("rigmanager", _rigInfo);
grdRigInfo.PopulateLabels(contractor, projectName, location, operatorName,
rigName, rigManager);
}
// A public method of my custom UserControl to update label content
public void PopulateLabels(string contractor, string project, string location,
string operatorName, string rigName, string manager)
{
lblContractor.Content = contractor;
lblProjectName.Content = project;
lblLocation.Content = location;
lblOperator.Content = operatorName;
lblRigName.Content = rigName;
lblRigManager.Content = manager;
}
My question is, how can I get the labels to update upon program start up? Thanks for any and all help.
EDIT
I have tried to call ShowRigInfo() both before and after InitializeComponent() of my main form. Neither of them changed the labels.
EDIT 2
Okay, I solved this before I actually saw the answers. What I did was moved my ShowRigInfo() into my custom UserControl, instead of my main form. I don’t know why I didn’t do that from the start, but there it is. I’ll be looking into the DataBinding portion of the answers. Thank you guys.
Well, because this is WPF, I would recommend binding those labels to properties in some sort of model which supports (implements) INotifyPropertyChanged.
If you Google with those words, you’ll come a long way.