Expression > Forums Home > Expression Studio Forums > Expression Blend + SketchFlow > Why is my custom property not shown?
Ask a questionAsk a question
 

AnswerWhy is my custom property not shown?

  • Friday, November 06, 2009 7:23 PMassassin316 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm building a custom Window and I'm now working on the Titlebar buttons, and have added this property:

     

    Public Shared AllowMinimizeProperty As DependencyProperty
    
    Public Property AllowMinimize() As Boolean
            Get
                Return CBool(GetValue(AllowMinimizeProperty))
            End Get
            Set(ByVal value As Boolean)
                SetValue(AllowMinimizeProperty, value)
    
                Dim img As Image = GetTemplateChild("imgMinimize")
    
                If img IsNot Nothing Then
                    img.Opacity = IIf(value, 1.0, 0.5)
                End If
            End Set
    End Property
    
    Public Sub New()
            AllowMinimizeProperty = DependencyProperty.Register("AllowMinimize", GetType(System.Boolean), GetType(BaseWindow), New UIPropertyMetadata(True))
    End Sub



    Now whenever I load up Blend, this property does not show up in the Miscellaneous section. If I change this property to NOT be a DependencyProperty, it will show, BUT it simple won't work. The image won't change it's opacity.

    What am I doing wrong?

Answers

  • Saturday, November 07, 2009 2:34 PMGuenter Schwaiger Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi assassin316,

    because when editing your Window in Blend the constructor of the root element (Window) is not called. Only the constructors of child elements are called. So your property is never registered.

    Try it out raise an execption in New() and edit the window in Blend.

    Hope it helps. 

    • Marked As Answer byassassin316 Sunday, November 08, 2009 2:37 PM
    •  
  • Wednesday, November 11, 2009 6:34 PMGuenter Schwaiger Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Try to register it  directly?

    Public Shared AllowMinimizeProperty As DependencyProperty = DependencyProperty.Register("AllowMinimize", GetType(System.Boolean), GetType(BaseWindow), New UIPropertyMetadata(True))

    Hope that helps.
    • Marked As Answer byassassin316 Saturday, November 14, 2009 9:06 PM
    •  

All Replies

  • Saturday, November 07, 2009 2:34 PMGuenter Schwaiger Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi assassin316,

    because when editing your Window in Blend the constructor of the root element (Window) is not called. Only the constructors of child elements are called. So your property is never registered.

    Try it out raise an execption in New() and edit the window in Blend.

    Hope it helps. 

    • Marked As Answer byassassin316 Sunday, November 08, 2009 2:37 PM
    •  
  • Sunday, November 08, 2009 2:37 PMassassin316 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    That is an interesting piece of info, thanks Guenter !   :)

    Coming back to this problem, how then can I go ahead and have my property show in Blend ???
  • Wednesday, November 11, 2009 5:49 PMassassin316 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Sorry, I need to bump this message to find a solution  :\
  • Wednesday, November 11, 2009 6:34 PMGuenter Schwaiger Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Try to register it  directly?

    Public Shared AllowMinimizeProperty As DependencyProperty = DependencyProperty.Register("AllowMinimize", GetType(System.Boolean), GetType(BaseWindow), New UIPropertyMetadata(True))

    Hope that helps.
    • Marked As Answer byassassin316 Saturday, November 14, 2009 9:06 PM
    •  
  • Wednesday, November 11, 2009 8:23 PMassassin316 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Perfect, i'll try that!

    Thanks again!

  • Friday, November 13, 2009 6:55 PMD. Matsumoto Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm learning about properties as well... just wondering if this solution worked for you?  If so, can you please mark it so us newbies know if it worked. :)  Thanks!
  • Saturday, November 14, 2009 9:06 PMassassin316 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes, it worked perfectly  :)  Just register the property on it's declaration, I've marked the answer above (answered by Guenter).