Bind to custom control properties defined in code behind
I have a custom control defined in code-behind:
Public Class MyControl
    Inherits Button
    Private _A As String
    Private _B As String
    Public Property A() As String
        Get
            Return A
        End Get
        Set(ByVal value As String)
            _A = value
        End Set
    End Property
    Public Property B() As String
        Get
            Return B
        End Get
        Set(ByVal value As String)
            B = value
        End Set
    End Property    
End Class
And here's the Markup:
<ControlTemplate TargetType="{x:Type local:MyControl}">
      <StackPanel>
         <TextBlock Text="{Binding ?????}"/&开发者_如何转开发gt; <!-- A Property -->
         <TextBlock Text="{Binding ?????}"/> <!-- B Property -->
       </StackPanel>
</ControlTemplate>
What code I have to write to bind to those properies?
{Binding Path=A, RelativeSource={RelativeSource AncestorType={x:Type MyControl}}}
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论