FrameworkElement`s DataContext Property does NOT inherit down the element tree

前端 未结 4 2077
情书的邮戳
情书的邮戳 2020-12-10 06:12

Hello WPF Pros at least I hope some of you read this!

DataContext is a property on FrameworkElement (base class for all WPF Controls) and is implemented as a Dep

4条回答
  •  臣服心动
    2020-12-10 06:32

    after reading this question and previous answers, I prefer using ContentControl with data triggered Content like this:

    Controls which will be set as Content of ContentControl:

    
       ...
    
    
       ...
    
    

    ContentControl which switch own content by DataTrigger in ContentControl style:

    
      
        
      
    
    

    I hope this helps to someone like previous answers to me.

提交回复
热议问题