wpfvb.nettriggersexpression-blend

Basic WPF question: How to add a custom property trigger?


I am using Expresion Blend 3 and created a new user control in my project. I want a storyboard to run if a custom property of that user control is triggered like with the ones shown here in the list..

alt text

I learnt you need a dependency property, but my understanding there is limited. Here's the basic code I set up with property "IsAwesome" as an example..

Partial Public Class simpleControl
    Public Sub New()
        MyBase.New()
        Me.InitializeComponent()
    End Sub

    Public Shared ReadOnly IsAwesomeProperty As DependencyProperty = _
        DependencyProperty.Register("IsAwesome", GetType(Boolean), GetType(simpleControl))

    Public Property IsAwesome() As Boolean
        Get
            Return DirectCast(Me.GetValue(IsAwesomeProperty), Boolean)
        End Get
        Set(ByVal value As Boolean)
            Me.SetValue(IsAwesomeProperty, value)
        End Set
    End Property
End Class

However, my property doesn't show in that list. What am I missing? Or is my entire approach wrong? Any help or advice would be appreciated!

Cheers


Solution

  • I created a new Wpf project. Added a new UserControl (UserControl1) with a custom dependency property called Foo.

    Then I opened Blend and added an instance of UserControl1 to Window1. I right clicked on UserControl1 and said EditTemplate | Edit a Copy.

    This created a copy of my user control template in the Window.Resources. From within this new template I went up to the Triggers panel and clicked the button to add a new property trigger.

    Right away Blend defaulted to selecting my property in the "Activated When" section.

    alt text http://blog.BradCunningham.net/Images/ForumImages/CustomDPInBlend.png

    You can grab my little sample app from here: http://blog.BradCunningham.net/SourceCode/ForumSamples/CustomDPInBlend.zip