title: System.InvalidOperationException on Button.Content in WPF
body: <p>Probably a stupid thing but I found the answer nowhere...</p>
  
  <p>I have the following code in my C# WPF Project:</p>
  
  <pre><code>string timer = "5:00"; 
  Button.Content = timer;
  </code></pre>
  
  <p>and it gives me <code>System.InvalidOperationException</code> once code execution reaches this point. It also doesn't work with <code>Button.Content = "5:00";</code> but funny enough in another function this code </p>
  
  <pre><code>string newLabel = Math.Floor(timerSec / 60f).ToString() + ":" + (timerSec % 60).ToString("0#");
  Button.Content = newLabel;
  </code></pre>
  
  <p>works just fine. What am I missing?</p>
  
  <p><code></code></p>
  
  <p><strong>//edit:</strong> the question cause confusion because it is pseudo code and I didn't think too much when I put it. here is how the button is actually defined:</p>
  
  <pre><code>&lt;Viewbox Grid.Row="1" Grid.Column="0"&gt;
       &lt;Button x:Name="_5v5OwnBlueButton" Content="5:00" Margin="5" /&gt;
  &lt;/Viewbox&gt;
  </code></pre>