Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are two things to know that should clear things up:</p> <p>First, in XAML, you can access static members through an instance of the type. You can also do this in VB.NET, for instance with this code:</p> <pre><code>Dim x = New MarkupViewModel() x.GetColumnTypes MarkupViewModel.GetColumnTypes </code></pre> <p>The last two lines are equivalent. In fact, the compiler rewrites the first line as the second. XAML is the same way. If you have an instance, you can access a static member through the same syntax as an instance member. (Other languages, like C# and F#, don't allow this syntax).</p> <p>Second, <code>ObjectDataProvider</code> calls a <em>method</em>, but <code>GetColumnTypes</code> is a <em>property</em>. If you had defined it as <code>static member GetColumnTypes() = ...</code> I would expect it to work.</p> <p>However, none of these approaches are really ideal. What you want to do is use the <a href="http://msdn.microsoft.com/en-us/library/ms742135.aspx" rel="nofollow">x:Static</a> markup extension. This is what it was designed for.</p> <p>In your namespace definitions (in the topmost tag of the XAML file), write something like this:</p> <pre><code>&lt;UserControl [...] xmlns:local="clr-namespace:Your.Namespace"&gt; </code></pre> <p>And then have the combo box declare its items like this:</p> <pre><code>&lt;ComboBox ItemsSource="{x:Static local:MarkupViewModel.GetColumnTypes}"&gt; </code></pre> <p>(although if you're keeping it as a property and not a function you should of course rename it as <code>ColumnTypes</code> not <code>GetColumnTypes</code>)</p> <p>Oh, and as for diagnosing binding errors, quite a lot of debugging information is available through <code>Visual Studio Options &gt; Debugging &gt; Output Window &gt; WPF Trace Settings</code>, which can dump a lot of information to the output window. However they can be somewhat difficult to interpret if you don't know WPF very well. An excellent general-purpose WPF utility is <a href="http://snoopwpf.codeplex.com/" rel="nofollow">Snoop</a>, which is good for many other reasons, but it can also display binding error information.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload