File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
src/WPFDevelopers.Shared/Core/Helpers Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 12
12
using System . Windows . Media ;
13
13
using System . Windows . Media . Animation ;
14
14
using System . Windows . Media . Imaging ;
15
- using WPFDevelopers . Controls ;
16
- using WPFDevelopers . Utilities ;
17
15
18
16
namespace WPFDevelopers . Helpers
19
17
{
@@ -254,6 +252,21 @@ public static Thickness GetPadding(FrameworkElement element)
254
252
return new Thickness ( ) ;
255
253
}
256
254
255
+ public static T FindVisualChild < T > ( DependencyObject parent ) where T : DependencyObject
256
+ {
257
+ int childCount = VisualTreeHelper . GetChildrenCount ( parent ) ;
258
+ for ( int i = 0 ; i < childCount ; i ++ )
259
+ {
260
+ var child = VisualTreeHelper . GetChild ( parent , i ) ;
261
+ if ( child is T typedChild )
262
+ return typedChild ;
263
+ var result = FindVisualChild < T > ( child ) ;
264
+ if ( result != null )
265
+ return result ;
266
+ }
267
+ return null ;
268
+ }
269
+
257
270
258
271
}
259
272
You can’t perform that action at this time.
0 commit comments