title: How to check if a String is a valid name for a FrameworkElement in WPF?
body: <p>In my code I'm assigning a String to the <a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.name.aspx" rel="nofollow">name property of a FrameworkElement</a>. This String is automatically generated from another part of the application and represents methods name in Java source code and therefore I want to check if it contains a valid name.</p>
  
  <p>Currently I'm doing it that way:</p>
  
  <pre><code>        private string getValidName(String s)
          {
              return s.Replace("&lt;", "").Replace("&gt;", "").Replace("#", "").Replace("(", "").Replace(")", "").Replace(",", "").Replace(".", "").Replace("$", "").Replace(" ", "");
          }
  </code></pre>
  
  <p>But the problem is that I don't know which letters I have to replace. For example in this code [ and ] are missing as I found out when I was hit with an Exception.</p>
  
  <p>So my question is. Is there a list of allowed symbols? And if yes how can I implement this in a reasonable way?</p>