How can I get access to the ScrollViewer inside a ComboBox in WPF?

前端 未结 1 608
终归单人心
终归单人心 2021-01-27 00:38

The ComboBox Control Template has a ScrollViewer. How can I get a reference to it from an instance of a ComboBox?

I tried naming it \"ScrollViwer1\" and using this, bu

相关标签:
1条回答
  • 2021-01-27 01:39

    You can use FrameworkTemplate.FindName Method.

    ScrollViewer sv = comboBox.Template.FindName("DropDownScrollViewer", comboBox) as ScrollViewer;
    if (sv != null)
    {
        // do something...
    }
    
    0 讨论(0)
提交回复
热议问题