Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: PropertyGrid custom type error

$
0
0
Hi,

This is how you should define your classes in VB when using Dependency properties :
Public Class myClass1
    Inherits DependencyObject
    Public Shared ReadOnly BrushProperty As DependencyProperty = DependencyProperty.Register("Brush", GetType(Brush), GetType(myClass1))
    Public Shared ReadOnly TextProperty As DependencyProperty = DependencyProperty.Register("Text", GetType(String), GetType(myClass1))


    Public Property Brush() As Brush
        Get
            Return DirectCast(GetValue(BrushProperty), Brush)
        End Get
        Set
            SetValue(BrushProperty, Value)
        End Set
    End Property

    Public Property Text As String
        Get
            Return DirectCast(GetValue(TextProperty), String)
        End Get
        Set
            SetValue(TextProperty, Value)
        End Set
    End Property


    Public Sub New(b As Brush, t As String)
        Brush = b
        Text = t
    End Sub

End Class
Public Class myClass2
    Inherits DependencyObject
    Public Shared ReadOnly BrushProperty As DependencyProperty = DependencyProperty.Register("Brush", GetType(Brush), GetType(myClass2))
    Public Shared ReadOnly TextProperty As DependencyProperty = DependencyProperty.Register("Text", GetType(String), GetType(myClass2))


    Public Property Brush() As Brush
        Get
            Return DirectCast(GetValue(BrushProperty), Brush)
        End Get
        Set
            SetValue(BrushProperty, Value)
        End Set
    End Property

    Public Property Text As String
        Get
            Return DirectCast(GetValue(TextProperty), String)
        End Get
        Set
            SetValue(TextProperty, Value)
        End Set
    End Property


    Public Sub New(b As Brush, t As String)
        Brush = b
        Text = t
    End Sub

End Class

Viewing all articles
Browse latest Browse all 2157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>