How to Bind To Data within a Datatemplate of a ContentControl

前端 未结 1 645
失恋的感觉
失恋的感觉 2020-12-28 14:09

I have the following simplified Example:

    

        
相关标签:
1条回答
  • 2020-12-28 14:51

    You need to bind the Content property of the ContentControl

    <ContentControl Content="{Binding}" ContentTemplate="{StaticResource PersonTemplate}" />
    

    This will set the DataContext of the ContentControl as Content of the control.

    Setting only the ContentTemplate property is not enough. The ContentControl does not implicitly use its DataContext as Content.

    0 讨论(0)
提交回复
热议问题