How do I get find my “CheckBox” item that is in the ItemTemplate?

前端 未结 4 596
深忆病人
深忆病人 2020-12-29 04:12

I have the following (very simple) ItemsControl:


    
         


        
4条回答
  •  天命终不由人
    2020-12-29 04:48

    I used the code that Kent and Timothy supplied, but this additional line was also needed for me.

    The whole code snippet goes:

    var container = _itemsControl.ItemContainerGenerator.ContainerFromItem(dahCurrentItem) as FrameworkElement;
    container.ApplyTemplate()
    var checkBox = _itemsControl.ItemTemplate.FindName("MyCheckBox", container) as CheckBox;
    

    Cheers!

提交回复
热议问题