A 'Binding' can only be set on a DependencyProperty of a DependencyObject

后端 未结 6 1327
陌清茗
陌清茗 2020-12-03 02:39

From a custom control based on TextBox, I created a property named Items, in this way:

public class NewTextBox : TextBox
{
    publ         


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 02:47

    I had the (runtime + designtime) message:

    An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

    Additional information: A 'Binding' cannot be set on the 'Property' property of type 'Trigger'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.

    Where I was smart enough to define a Trigger on a VM property..

    // incorrect.. cannot have Trigger for VM property
    
      
    
    

    Which should of course be a datatrigger (which uses Binding instead of Property)

    
      
    
    

    Triggers are typically for Controls (Button, TextBox, FrameworkElement etc.) properties.

提交回复
热议问题