WPF Control's Nested property's data binding

后端 未结 1 1786
礼貌的吻别
礼貌的吻别 2021-01-20 00:21

I\'m trying to develop user control with some nested properties that allows to use databinding to set it. For example, I have something like this:

// Top lev         


        
相关标签:
1条回答
  • 2021-01-20 00:47

    H.B. right, nested control does not inherit DataContext from mycontrol. Tyr out setting it explicitly:

    <local:mycontrol x:name="myControl" 
                     topleveltestproperty="{Binding Value}" >          
       <local:mycontrol.nestedobject>             
               <local:mynestedtype x:name="myNestedControl" 
                                   DataContext="{Binding ElementName=myControl,
                                                         Path=DataContext}"
                                   nestedtestproperty="{Binding Value}" />          
      </local:mycontrol.nestedobject>       
    </local:mycontrol> 
    
    0 讨论(0)
提交回复
热议问题