Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Binding error: Attached Dependency Property not found
    primarykey
    data
    text
    <p>I am trying to resolve a number of frequently occurring data binding errors as given below</p> <pre><code>System.Windows.Data Error: 40 : BindingExpression path error: 'Active' property not found on 'object' ''FrameViewModel' (HashCode=55649279)'. BindingExpression:Path=Active; DataItem='FrameViewModel' (HashCode=55649279); target element is 'ContentControl' (Name='HeaderBorder'); target property is 'NoTarget' (type 'Object') </code></pre> <p>I have an attached dependency property Active</p> <pre><code>public bool Active { get { return (bool)GetValue(ActiveProperty); } set { SetValue(ActiveProperty, value); } } public static readonly DependencyProperty ActiveProperty = DependencyProperty.RegisterAttached("Active", typeof(bool), typeof(Card)); </code></pre> <p>The binding is set in theme files in a control template</p> <pre><code>&lt;ControlTemplate x:Key="FrameHeader" TargetType="ContentControl"&gt; ..... ..... &lt;ControlTemplate.Triggers&gt; &lt;DataTrigger Binding="{Binding Path=Active}" Value="True"&gt; &lt;Setter TargetName="HeaderBackground" Property="Background" Value="{DynamicResource SelectedHeaderBrush}"/&gt; &lt;/DataTrigger&gt; &lt;DataTrigger Binding="{Binding Path=Active}" Value="False"&gt; &lt;Setter TargetName="HeaderBackground" Property="Background" Value="{DynamicResource HeaderBrush}"/&gt; &lt;/DataTrigger&gt; &lt;/ControlTemplate.Triggers&gt; </code></pre> <p>The control template is used in a content control as shown here (can be seen in the error as well)</p> <pre><code>&lt;ControlTemplate x:Key="Card" TargetType="{x:Type Button}"&gt; &lt;ContentControl Template="{DynamicResource FrameTemplate}"&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="*" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;ContentControl Template="{DynamicResource FrameHeader}" Grid.Row="0" x:Name="HeaderBorder" &gt; &lt;Border Style="{DynamicResource BorderTop}"&gt; &lt;DockPanel&gt; &lt;ContentPresenter x:Name="UpperLeftContent" DockPanel.Dock="Left" Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=icush:Frame}, Converter={StaticResource WatchListLockoutTimerVisibilityConverter}, Path=UpperLeftContent}" Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=icush:Frame}, Converter={StaticResource WatchListLockoutTimerConverter}, ConverterParameter={StaticResource LockoutTimerRadius}, Path=UpperLeftContent}" /&gt; &lt;TextBlock x:Name="Header" Style="{DynamicResource Header}" Text="{Binding Path=Title}" /&gt; &lt;/DockPanel&gt; &lt;/Border&gt; &lt;/ContentControl&gt; &lt;ContentControl Template="{DynamicResource FrameBody}" Grid.Row="1" Content="{TemplateBinding Content}"/&gt; &lt;/Grid&gt; &lt;/ContentControl&gt; &lt;/ControlTemplate&gt; </code></pre> <p>I have spent a lot of time trying to figure out if the DependencyProperty is missing anything or if the binding is set incorrectly but to no avail. The application works as expected but I'm trying to get rid of such binding errors. The error goes away if I remove the binding in XML but that is not the solution I'm looking for. There might be something wrong with the binding.</p> <p>I have looked at several other posts, read material and book chapters on Dependency Properties and binding and I can't find any obvious mistake. I have even used snoop but didn't get any additional information from that too. Some of the things I've looked at are given below</p> <p><a href="https://stackoverflow.com/questions/5382164/bindingexpression-path-error-property-not-found-on-object">BindingExpression path error: property not found on &#39;object&#39;</a></p> <p><a href="https://stackoverflow.com/questions/19228677/system-windows-data-error-40-bindingexpression-path-error-property-not-found">System.Windows.Data Error: 40 : BindingExpression path error: property not found on object</a></p> <p><a href="https://stackoverflow.com/questions/16173869/wpf-error-40-bindingexpression-path-error-property-not-found-on-object">WPF Error 40 BindingExpression path error: property not found on &#39;object&#39;</a></p> <p><a href="http://wpftutorial.net/DependencyProperties.html" rel="nofollow noreferrer">http://wpftutorial.net/DependencyProperties.html</a></p> <p><a href="http://rachel53461.wordpress.com/2012/07/14/what-is-this-datacontext-you-speak-of/" rel="nofollow noreferrer">http://rachel53461.wordpress.com/2012/07/14/what-is-this-datacontext-you-speak-of/</a></p> <p><a href="https://stackoverflow.com/questions/14510931/is-there-a-way-to-determine-where-is-a-wpf-binding-declared-created/14523290#14523290">Is there a way to determine where a WPF Binding is declared/created?</a></p> <p><a href="https://stackoverflow.com/questions/17492359/wpf-slow-performance-many-dataitem-null-binding-warnings">WPF slow performance - many DataItem=null binding warnings</a></p> <p>Any ideas of what could be going wrong and how I can get rid of the error?</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.
 

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