Why would 'this.ContentTemplate.FindName' throw an InvalidOperationException on its own template?

前端 未结 3 1118
借酒劲吻你
借酒劲吻你 2020-12-09 17:18

Ok... this has me stumped. I\'ve overridden OnContentTemplateChanged in my UserControl. I\'m checking that the value passed in for newContentTemplate does in fact equal th

3条回答
  •  囚心锁ツ
    2020-12-09 17:47

    The ContentTemplate isn't applied to the ContentPresenter until after that event. While the ContentTemplate property is set on the control at that point, it hasn't been pushed down to bindings internal to the ControlTemplate, like the ContentPresenter's ContentTemplate.

    What are you ultimately trying to do with the ContentTemplate? There might be a better overall approach to reach your end goal.

提交回复
热议问题