Method TryGetSource
TryGetSource(WeakReference<View>?, out View?)
Tries to get the source View from a WeakReference<T>.
public static bool TryGetSource(this WeakReference<View>? weakRef, out View? source)
Parameters
weakRefWeakReference<View>sourceViewWhen this method returns, contains the target View if the weak reference is not null and the target is still alive; otherwise, null.
Returns
Remarks
This is a convenience method to simplify the common pattern of checking a weak reference and retrieving its target. It's particularly useful with Source.
Example usage:
if (commandContext.Source.TryGetSource(out View? view))
{
// use view
}