New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RaiseEvent generic extension method #8999
Comments
Maybe not an extension method, more akin to a namespace System.Windows;
public class UIElement
{
// ...
private void OnRaisedEvent(RoutedEventArgs e) { /* ... */ }
public void RaiseEvent(RoutedEventArgs e) => OnRaisedEvent(e);
public void RaiseEvent<TArguments>(TArguments e) where TArguments : RoutedEventArgs => OnRaisedEvent(e);
// ...
} Anyway, you get the idea. |
What do you mean by this? Which language features? Why do you need a generic method, what benefit does it have? |
I illustrated the benefit in the |
It seems like an intriguing proposition, but the improvements appear to be minimal and it doesn’t seem to offer much convenience. Nonetheless, I appreciate your suggestion as it can spark inspiration. |
No problem. Admittedly, the scope is small, yes; that is my particular focus right at the moment, as I am evaluating attached routed events, whether it might help in an opportunity I have at the moment. I did not assess other functions, whether generic versions might benefit there as well. |
Add a convenience extension method allowing for contemporary and planned language level features to be more prominently used.
And in practical usage, assuming appropriate event declarations, etc:
For sake of example:
Tangentially, although at first glance, it seems counterintuitive why we would need to relay the
RoutedEventArgs.RoutedEvent
, especially given theevent
mechanism. Might seem better to do something like:And then since DependencyObject is handling the decoupled bookkeeping for us, we can focus more on the arguments properties themselves without having to also concern ourselves with the bookkeeping, even in raising the event.
The text was updated successfully, but these errors were encountered: