1

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 ?????}"/> <!-- A Property -->
         <TextBlock Text="{Binding ?????}"/> <!-- B Property -->
       </StackPanel>
</ControlTemplate>

What code I have to write to bind to those properies?

Cobold
  • 2,563
  • 6
  • 34
  • 51

1 Answers1

2
{Binding Path=A, RelativeSource={RelativeSource AncestorType={x:Type MyControl}}}
kenwarner
  • 28,650
  • 28
  • 130
  • 173