title: How do I access the child element of a Frame?
body: <p>I have frames in my main window which are set to visible/collapsed based on user input:</p>
  
  <pre><code>&lt;Grid&gt;
      &lt;ScrollViewer x:Name="ScrollViewer1" Grid.Row="1" Grid.ColumnSpan="3" Margin="10,0,0,0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"&gt;
             &lt;Frame Name="InputsFrame" Source="Inputs.xaml" NavigationUIVisibility="Hidden" Visibility="Visible" 
                     ScrollViewer.CanContentScroll="True" /&gt;
      &lt;/ScrollViewer&gt;
  
      &lt;ScrollViewer x:Name="ScrollViewer2" Grid.Row="1" Grid.ColumnSpan="3" Margin="10,0,0,0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Visibility="Collapsed"&gt;
          &lt;Frame Name="LoadCasesFrame" Source="LoadCases.xaml" NavigationUIVisibility="Hidden" Visibility="Collapsed"
                     ScrollViewer.CanContentScroll="True" /&gt;
      &lt;/ScrollViewer&gt;
  
      &lt;!-- etc --&gt;
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p>The Inputs.xaml frame basically just consists of a 3rd party DoubleTextBox control (over 100 of them), and the user can just enter in values to that page. C# code behind:</p>
  
  <pre><code>private void InputsTab_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  {
      LoadCasesFrame.Visibility = Visibility.Collapsed;
      ScrollViewer2.Visibility = Visibility.Collapsed;
  
      InputsFrame.Visibility = Visibility.Visible;
      ScrollViewer1.Visibility = Visibility.Visible;
  }
  </code></pre>
  
  <p>In this main window, there is a menu on top to allow for saving and opening the file. When I open the file, I want the data to be read (which I am able to do successfully) and also for the UI in the Inputs.xaml file to be updated.</p>
  
  <p>The following code is in Inputs.xaml.cs:</p>
  
  <pre><code>public void LoadValues()
  {
      List&lt;DoubleTextBox&gt; dtb1 = App.GetLogicalChildCollection&lt;DoubleTextBox&gt;(inputsGrid);
  
      for (int i = 0; i &lt; dtb1.Count; i++)
      {
          foreach (var keyValuePair in App.globalDictionary)
          {
              var doubleTextBox = dtb1[i] as DoubleTextBox;
  
              if (doubleTextBox.Name == keyValuePair.Key)
              {
                  doubleTextBox.Value = 500;
                  break;
              }
          }
      }
  }
  </code></pre>
  
  <p>This function works (all the values in the GUI update to 500) when I call it from the Inputs.xml.cs page (for example, when I put it in the <code>Page_Loaded</code> event). However, I need to call this function from the <code>MainWindow</code>, since that is where the event handler for the Open File event is located:</p>
  
  <pre><code>private void openProject_Click(object sender, RoutedEventArgs e)
  {
      OpenFileDialog openFileDialog = new OpenFileDialog();
      if (openFileDialog.ShowDialog() == true)
      {
          string stringToDeserialize = File.ReadAllText(openFileDialog.FileName);
          App.DeserializeJSONString(stringToDeserialize);
      }
  
      // call LoadValues here
  }
  </code></pre>
  
  <p>Calling <code>LoadValues()</code> above doesn't update the GUI in the Input.xaml page. I originally had something like this in my <code>MainWindow</code>:</p>
  
  <pre><code>Inputs _inputs = new Inputs();
  _inputs.LoadValues();
  </code></pre>
  
  <p>I know that the problem is that I have created a new object for <code>Inputs</code> and that's probably why it's not working. I'm unsure how to do it so that I don't use a new object -- wonder if I could use the <code>InputsFrame</code> somehow. I've also tried using event handlers to no success.</p>