title: How to know if text is bigger than textbox?
body: <p>Is there a way to know if my text within a wpf textbox has exceeded the length of it?</p>
  
  <p><strong>NOTE: I'M TALKING ABOUT PIXEL LENGTH NOT CHARACTER LENGTH OF MAXLENGTH</strong></p>
  
  <p>So basically, if the textbox is 50 pixels long.
  And I have a text in it that is:
  "Supercalifragilisticexpialidocious! Even though the sound of it is something quite atrosicous"</p>
  
  <p>Then it won't fit in there right? I'd like to KNOW that it didn't fit in it.
  But if the textbox is 900 pixels wide. It just might.</p>
  
  <p>I'm currently checking with something like the following.</p>
  
  <pre><code>private double GetWidthOfText()
  {
      FormattedText formattedText = new FormattedText(MyTextbox.Text,
          System.Globalization.CultureInfo.GetCultureInfo("en-us"),
          FlowDirection.LeftToRight, new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Bold, FontStretches.Normal), MyTextbox.FontSize, Brushes.Black);
      return formattedText.Width;
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>if (textBox.Width &lt; GetWidthOfText()) ...
  </code></pre>
  
  <p>But I find it to be incredibly hacky and never really works. I'm trying to find something more reliable. Any ideas?</p>