Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

wpf app how to get all elements which are exposed to script

   public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
        {
            if (depObj == null)
            {
                yield return null;
            }
            else
            {
                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
                {
                    var child = VisualTreeHelper.GetChild(depObj, i);

                    if (child != null && child is T)
                        yield return (T)child;

                    foreach (T childOfChild in FindVisualChildren<T>(child))
                        yield return childOfChild;
                }
            }
        }
//usage:

foreach (var tb in FindVisualChildren<TextBlock>(window))
{
    // do something with tb here
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: winforms C# code cross thread operation is not valid 
Csharp :: how to add item in list at first position c# 
Csharp :: average c# 
Csharp :: increment operator c# 
Csharp :: {"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."} 
Csharp :: c# add to array 
Csharp :: C# function return datareader 
Csharp :: c# iterate enum 
Csharp :: c# double to int 
Csharp :: how to work with ascii in c# 
Csharp :: raylib c# basic window 
Csharp :: C# add two numbers using a method 
Csharp :: string to camel case c# 
Csharp :: .net core copy directory to output 
Csharp :: write last element of dictionary c# 
Csharp :: c# datagridview header color 
Csharp :: How does works Unity interfaces 
Csharp :: c# settings file 
Csharp :: c# get last day of month 
Csharp :: c# array.join 
Csharp :: c# sort for loop 
Csharp :: orElseThrow 
Csharp :: asp.net mvc get current url in view 
Csharp :: c# add element to array 
Csharp :: check if an object is active unity 
Csharp :: priority queue c# 
Csharp :: C# new form 
Csharp :: C# short getter setter 
Csharp :: cause bsod c# 
Csharp :: combobox selected item c# 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =