Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I know that this is not the direct answer to your question. </p> <p>If you know the name of the control element, that you expect to be bound against you can do something like the test below (using nunit). This is the rough version. But here you use expressions and explicitly test that the property is in a binding</p> <pre><code> [Test] public void TestBindings() { TestBinding&lt;IndividualSolutionViewModel, string&gt;(x =&gt; x.Name, "Name", TextBlock.TextProperty); } private void TestBinding&lt;TViewModel,TResult&gt;(Expression&lt;Func&lt;TViewModel, TResult&gt;&gt; property, string elementName, DependencyProperty dependencyProperty) { string memberName = ExpressionHelper.GetPropertyName(property); // f.ex v =&gt; v.Name will return Name TestBinding(memberName, elementName, dependencyProperty); } private void TestBinding(string memberName, string elementInControlName, DependencyProperty dependencyProperty) { //object viewModel = new IndividualSolutionViewModel(); var view = new IndividualSolutionView(); //Assert.That(view.DataContext, Is.EqualTo(viewModel)); var element = view.FindName(elementInControlName); Assert.That(element, Is.Not.Null, string.Format("Unable to find the element {0} in view {1}", elementInControlName, view.Name)); Assert.That(element, Is.InstanceOf(typeof(DependencyObject))); var binding = BindingOperations.GetBinding(element as DependencyObject, dependencyProperty); Assert.That(binding, Is.Not.Null, string.Format("Could not find a binding for the control {0}", elementInControlName)); Assert.That(binding.Path.Path, Is.EqualTo(memberName)); } </code></pre> <p>Ps. You have to add this to the app.config</p> <pre><code>&lt;configSections&gt; &lt;sectionGroup name="NUnit"&gt; &lt;section type="System.Configuration.NameValueSectionHandler" name="TestRunner"&gt;&lt;/section&gt; &lt;/sectionGroup&gt; &lt;/configSections&gt; &lt;NUnit&gt; &lt;TestRunner&gt; &lt;add value="STA" key="ApartmentState"&gt;&lt;/add&gt; &lt;/TestRunner&gt; &lt;/NUnit&gt; </code></pre>
 

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