简体   繁体   中英

How to use foreach (Control c in this.Controls) in WPF


Hello every one!
How Can I use this code in WPF (sorry, I'm beginner):

foreach (Control c in this.Controls)
{

}

(i want change opacity of elements one after another!)

WPF doesn't have the concept of controls the same way WinForms does.
You need to determine if it's a ContentControl or a Panel. ContentControl has Content of object and Panel has Children of UIElement.

Look at my answer on this question... I show how to cycle the controls and I explain it as well.

Link to Get all Controls with explanation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM