-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented browsers search results Pg Up/Down navigation.
- Loading branch information
Sergey M
committed
Aug 29, 2020
1 parent
dd1a724
commit ac1d56b
Showing
2 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Windows.Media; | ||
|
||
namespace DPackRx.Extensions | ||
{ | ||
public static class UIExtensions | ||
{ | ||
/// <summary> | ||
/// Custom: returns child element of a given type. | ||
/// </summary> | ||
public static T GetChild<T>(this Visual element) where T : Visual | ||
{ | ||
if (element == null) | ||
return default; | ||
|
||
if (element.GetType() == typeof(T)) | ||
return element as T; | ||
|
||
T result = null; | ||
|
||
for (var index = 0; index < VisualTreeHelper.GetChildrenCount(element); index++) | ||
{ | ||
var visualElement = VisualTreeHelper.GetChild(element, index) as Visual; | ||
result = visualElement.GetChild<T>(); | ||
if (result != null) | ||
break; | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters