user1153896
user1153896

Reputation: 303

How to bind to the control's dependency property inside ControlTemplate

I've extended PopupBaseEdit control by adding my own ControlTemplate and a new DependencyProperty PopupText to the extended control. The property PopupText is initialized from the control's consumer. No issues here. The question is; how do I bind TextBox.Text to my attached property inside ControlContent?

Here is the XAML:

<ControlTemplate x:Key="myPopuptemplate">
  <StackPanel>
    <TextBox Margin="5" Text="???????"/>
  </StackPanel>
</ControlTemplate>
<Style TargetType="local:myControl">
  <Setter Property="PopupContentTemplate" 
          Value="{StaticResource myPopuptemplate}"/>
</Style>

Upvotes: 1

Views: 1504

Answers (1)

brunnerh
brunnerh

Reputation: 185445

Use a TemplateBinding.

Upvotes: 3

Related Questions