title: Only allow to input at least 1-digit and at most 2-digit number in DecimalUpDown in WPF
body: <p>I use DecimalUpDown in xctk for user to input at least 1-digit and at most 2-digit number. </p>
  
  <p><a href="https://i.stack.imgur.com/j4bSs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j4bSs.png" alt="enter image description here"></a></p>
  
  <p>The xaml code in shown below.</p>
  
  <pre><code>&lt;xctk:IntegerUpDown Name="hourBox" Margin="0,0,0,1" ShowButtonSpinner="False" Text="0" 
                      Grid.Row="0" Maximum="50" Minimum="0" ClipValueToMinMax="True"
                      FontSize="22" TextAlignment="Center" PreviewTextInput="PreviewNumInput"/&gt;
  </code></pre>
  
  <p>The following code is for <code>PreviewTextInput</code>:</p>
  
  <pre><code>private void PreviewNumInput(object sender, TextCompositionEventArgs e) 
  {
      if (!IsPositiveNum(e.Text))
          e.Handled = true;
  }
  
  private bool IsPositiveNum(string str) 
  {
      int x;
      if (int.TryParse(str, out x) &amp;&amp; x &gt;= 0)
          return true;
      return false;
  }
  </code></pre>
  
  <p>How can I allow user to only input <strong>at least 1-digit</strong> and <strong>at most 2-digit</strong> number between <strong>0</strong> and <strong>50</strong> before value clipping on out-focus?</p>
  
  <p>For example:</p>
  
  <pre><code>0
  15
  48
  50
  86   (Not Allowed)
  123  (Not Allowed)
  </code></pre>
  
  <p><br/></p>
  
  <h2>References</h2>
  
  <ul>
  <li><a href="https://wpftoolkit.codeplex.com/wikipage?title=DecimalUpDown&amp;referringTitle=Home" rel="nofollow noreferrer">DecimalUpDown - Extended WPF Toolkit™ Community Edition</a></li>
  </ul>
  
  <p><br/></p>