I am creating a new tab and document (Frame) upon a button click. In order to prevent multiple of the same window I am trying to check and see if this window already exists by attempting to find it by name, however it can't seem to find it, although it is listed as a Child at runtime.
private void NewWeighButton_Click(object sender, RoutedEventArgs e)
{
//Check if the window is already open, if it is focus it, if not create it.
if (SyncDockingManager.FindName("NewWeigh") == null)
{
Frame newWeighFrame = new Frame();
newWeighFrame.Content = new SelectACPage(new SelectAircraftViewModel(Context));
newWeighFrame.Name = "NewWeigh";
DockingManager.SetHeader(newWeighFrame, "New Weigh");
DockingManager.SetState(newWeighFrame, DockState.Document);
DockingManager.SetIsSelectedTab(newWeighFrame, true);
SyncDockingManager.Children.Add(newWeighFrame);
}
else
{
SyncDockingManager.FindName("NewWeigh");
}
}