title: System.Windows.Data Error: 4 : Cannot find source for binding with reference
body: <p>I have 3 Projects in a single VS 2012 solution. Below is the XAML file that is throwing this error is in Project A. The <code>BmpImage.cs</code> file exists in different project B in the same solution which contains all the extensions and helper files and contains all methods and code that is required. Project A references Project B.</p>
  <p>Anyone could help, please? My job is on the line here but I am stuck. I have read all other similar questions but none does address this issue.</p>
  <p>I am getting this error :</p>
  <blockquote>
  <p>System.Windows.Data Error: 4 : Cannot find source for binding with
  reference 'RelativeSource FindAncestor,
  AncestorType='System.Windows.Controls.Button', AncestorLevel='1''.
  BindingExpression:Path=IsEnabled; DataItem=null; target element is
  'BmpImage' (Name=''); target property is 'NoTarget' (type 'Object')</p>
  </blockquote>
  <pre><code>&lt;UserControl x:Class=&quot;MyGrid.MyPanel&quot; 
           Name=&quot;_ctrl&quot; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; 
           xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; 
           xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; 
           xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; 
           xmlns:ex=&quot;clr-namespace:Helper.Xaml;assembly=Helper.Xaml&quot; 
           xmlns:sx=&quot;clr-namespace:MyPanel.Xaml;assembly=MyPanel.Xaml&quot;&gt;
  &lt;UserControl.Resources&gt;
      **&lt;Style x:Key=&quot;BmpStyle&quot; TargetType=&quot;{x:Type ex:BmpImage}&quot;&gt;
           &lt;Style.Triggers&gt;
              &lt;DataTrigger Binding=&quot;{Binding RelativeSource={RelativeSource AncestorType={x:Type  Button}, AncestorLevel=1}, Path=IsEnabled}&quot; Value=&quot;False&quot;&gt;
                &lt;Setter Property=&quot;UIElement.Opacity&quot; Value=&quot;0.3&quot; /&gt;
              &lt;/DataTrigger&gt;
           &lt;/Style.Triggers&gt;
      &lt;/Style&gt;**
  &lt;/UserControl.Resources&gt;
  &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
           &lt;RowDefinition Height=&quot;Auto&quot; /&gt;
           &lt;RowDefinition Height=&quot;*&quot; /&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;ToolBar ToolBarTray.IsLocked=&quot;True&quot;&gt;
           &lt;Button ToolTip=&quot;Filter...&quot; ToolTipService.ShowOnDisabled=&quot;True&quot; Click=&quot;Filter_OnClick&quot;&gt;
               &lt;ex:BmpImage Source=&quot;Images/filter.png&quot; Style=&quot;{StaticResource BmpStyle}&quot; /&gt;
           &lt;/Button&gt;
           &lt;ToggleButton ToolTip=&quot;AutoScroll&quot; ToolTipService.ShowOnDisabled=&quot;True&quot; IsChecked=&quot;{Binding ElementName=Trades, Path=AutoScroll}&quot;&gt;
              &lt;ex:BmpImage Source=&quot;Images/Autoscroll.png&quot; Style=&quot;{StaticResource BmpStyle}&quot; /&gt;
           &lt;/ToggleButton&gt;
      &lt;/ToolBar&gt;
      &lt;sx:PanelGrid Name=&quot;PanelGrid&quot; Grid.Row=&quot;1&quot; /&gt;
  &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>