--- lang: ja-jp breaks: true --- # UWP WPF `WinUI 3` XAMLの親要素を取得する 2021-04-14 > 【WPF】意外に役に立つかもしれないVisualTreeHelper.GetParentメソッド > http://pro.art55.jp/?eid=878693 ```csharp= public static T? GetParentItem<T>(FrameworkElement startElement) where T : class { Type targetType = typeof(T); DependencyObject result = startElement; do { result = VisualTreeHelper.GetParent(result); if (result == null) { return null; } } while (result.GetType().Equals(targetType) == false); return (T)(object)result; } ``` ###### tags: `UWP` `WPF` `XAML` `親要素` `WinUI 3`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up