title: Best way to get a user to input a correctly-formatted URL?
body: <p>I am creating a dialog using MVVM which prompts the user to type in an http:// URL to a KML file. The "OK" button needs to be enabled when the URL is in the correct format, and it needs to be disabled when the URL is in an incorrect format.</p>
  
  <p>Right now the button is bound to an ICommand, and the logic for CanExecute() looks like this:</p>
  
  <pre><code>return !string.IsNullOrEmpty(CustomUrl);
  </code></pre>
  
  <p>The command's CanExecuteChanged event is raised on every keystroke, and so far it's working well.</p>
  
  <p>Now I want to do a little bit of actual validation. The only way I know to do that is as follows:</p>
  
  <pre><code>try
  {
      var uri = new Uri(CustomUrl);
  }
  catch (UriFormatException)
  {
      return false;
  }
  
  return true;
  </code></pre>
  
  <p>That's no bueno, especially since the validation is happening on each keystroke. I could make it so that the URI is validated when the user hits the OK button, but I'd rather not. Is there a better way to validate the URI other than catching exceptions?</p>