Search

RoutedEventArgs.Empty should be RoutedEventArgs by Jan Kucera

Closed
as By Design Help for as By Design

2
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 292848
Opened: 8/12/2007 2:22:21 PM
Access Restriction: Public
0
Workaround(s)
1
User(s) can reproduce this bug
Hello,
this is just to note you that RoutedEventArgs.Empty returns an object of type EventArgs which is not implicitly convertible to RoutedEventArgs, resulting in failure when passing RoutedEventArgs.Empty (and making this member useless).
Details (expand)
Product Language
English

Version

Visual Studio Code Name "Orcas" (Beta 2)
Operating System
Windows Vista
Operating System Language
English
Steps to Reproduce
Create (or autogenerate) an EventHandler, like

private void RadioButton_Checked(object sender, RoutedEventArgs e) { }

Try to call the method from code,
RadioButton_Checked(null, RoutedEventArgs.Empty).
Actual Results
Argument '2': cannot convert from 'System.EventArgs' to 'System.Windows.RoutedEventArgs'.

There is no reason to introduce RoutedEventArgs.Empty in addition to EventArgs.Empty.
Expected Results
Be able to pass RoutedEventArgs.Empty to an routed event handler.

(Make the RoutedEventArgs.Empty of type RoutedEventArgs)
TAP Code (if applicable)
 
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey. [Details]

 

File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 8/12/2007 at 8:33 PM
Thank you for your feedback. We are currently investigating. If this issue is urgent, please call support directly (see http://support.microsoft.com). Thank you, Visual Studio Product Team.
Posted by Microsoft on 8/13/2007 at 3:36 AM
Thanks for your feedback. We have reproduced this bug on Visual Studio 2008 Beta 2, and we are sending this bug to the appropriate group within the VisualStudio Product Team for triage and resolution.

Thank you,
Visual Studio Product Team.
Posted by Jan Kucera on 8/15/2007 at 4:39 AM
Actually I see the Empty member is inherited from System.EventArgs.
And all derivates of RoutedEventArgs has it as well, like TextChangedEventArgs.Empty cannot be passed to TextChangedEventArgs parameter.

In fact there is no way to supply empty event args to an routed event.

I don't know what the optimal solution would be, but perhaps each derivate should either 1) override the Empty member to the instance of itself, or 2) be implicitly (at worst explicitly) convertible from EventArgs, which is perhaps easier but does not make much sense.
Posted by Jan Kucera on 1/5/2010 at 6:36 AM
What about to add static RoutedEventArgs.RoutedEmpty field?