How to Find WPF Child Control by Name or Type

How to Find WPF Child Control by Name or Type ?

Sử dụng VisualTreeHelper 


cách dùng: Ví dụ tìm Grid trong một ListBox ItemTemplate có tên ListBox1
Grid itemGrid = FindVisualChild <Grid>(ListBox1, "YourGridName");
Reference : https://stackoverflow.com/questions/636383/how-can-i-find-wpf-controls-by-name-or-type https://stopbyte.com/t/how-to-find-wpf-child-control-by-name-or-type/136/2

Post a Comment

أحدث أقدم