title: Reference namespaceless class in xaml
body: <p>I have a class without namespace (should I say, declared in <em>global</em> namespace?)</p>
  
  <pre><code>public static class Test
  {
      public static string Something { get; set; }
  }
  </code></pre>
  
  <p>It can be accessed from other classes of the project without specifying any namespace, like it's located in the <em>same</em> namespace</p>
  
  <pre><code>namespace WpfApplication1
  {
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              Test.Something = "bla"; // no problem
              InitializeComponent();
          }
      }
  }
  </code></pre>
  
  <p>Now I am trying to access such class from xaml. And I have problems.</p>
  
  <hr>
  
  <p>Typing its name like this</p>
  
  <pre><code>    &lt;TextBlock Text="{Binding Source={x:Static Test.Something}}"/&gt;
  </code></pre>
  
  <p>gives <em>intellisence error</em></p>
  
  <blockquote>
    <p>Test is not supported in WPF project.</p>
  </blockquote>
  
  <hr>
  
  <p>Trying to add <code>clr-namespace</code></p>
  
  <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:WpfApplication1"&gt;
      ...
      &lt;TextBlock Text="{Binding Source={x:Static local:Test.Something}}"/&gt;
  </code></pre>
  
  <p>will produce <em>compiler error</em></p>
  
  <blockquote>
    <p>Cannot find the type 'Test'. Note that type names are case sensitive.  </p>
  </blockquote>
  
  <p>Strangely enough, intellisence think everything is ok this time</p>
  
  <p><img src="https://i.stack.imgur.com/IW1uq.png" alt="OMG"></p>
  
  <hr>
  
  <p>Putting <code>Test</code> into <code>WpfApplication1</code> namespace will make it working ofc. But I want to have it without namespace.</p>
  
  <p>Question: How to declare <em>global</em> namespace as prefix in xaml? Is it really that <em>bad</em> to have some classes without namespace? My idea was to use same class in different projects (as a <a href="https://stackoverflow.com/a/15907515/1997232">link</a>) without making dll (one exe-file, I know it is possible to embed dll into exe, but seriously ...) or copying cs-files (would required simultaneous editing multiple cs-files if class has to be updated, very bad).</p>
  
  <hr>
  
  <p>I though about one more possibility to demonstrate problem. Imagine we have something declared in different namespace (to example, project namespace is <code>WpfApplication1</code>, but we create class and declare it in <code>SomeNamespace</code> namespace). This will required to use <code>using</code> or specify <em>full name</em> (including namespace, but excluding assembly) when accessing it inside project classes. However, in <code>xaml</code> we have only option similar to <code>using</code> - it's <code>clr-namespace</code>. What about specifying <em>full name</em> directly in xaml right at the place where it's needed and without using of <code>clr-namespace</code>. Is it possible?</p>