wpf force to build visual tree

前端 未结 1 1129
温柔的废话
温柔的废话 2020-12-11 06:41

I have ItemsControl with Grid as ItemsPanelTemplate


    

        
相关标签:
1条回答
  • 2020-12-11 07:38

    You can make a call to ApplyTemplate this tells the element to apply the template and build the visual tree.

    Although, this doesn't apply templates all the way down. In this case you would first have to call ApplyTemplate() on the ItemsControl, then var item_presenter = FindVisualChild<ItemsPresenter>(items_control), then you have to call item_presenter.ApplyTemplate() and now you will have forced the Grid into the VisualTree.

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