views:

39

answers:

1

Hi Experts,

I have a user control which is having a listview inside it. The SelectionChanged event of this list view is handled inside the user control. The code for the same is as follows:

        private void lstvMyView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {...}

I want to call this handler again from some other place inside the user control. So to call this handler i need the "SelectionChangedEventArgs" there. When I am trying to create the instance of "SelectionChangedEventArgs", i am unable to understand what should I pass as parameters to the constructor of "SelectionChangedEventArgs".

The place from where I am suppose to call this handler does not add or remove any items in the listview. It just navigates in the items in the listview thereby changing the selectedindex of the listview.

I am trying to do something like this. The below code is obviously incorrect.

lstvMyView_SelectionChanged(_lstvMyView, new SelectionChangedEventArgs());

Please Help!

Thanks in Advance!

Regards, Samar

+2  A: 

I want to call this handler again from some other place inside the user control

Don't. An event handler is not supposed to be called explicitly from your code. Whatever you're doing in this handler, you can put it in another method that only takes the parameters it needs, and call that method from your code.

Thomas Levesque
Hmm... But what if the code in the handler is using e in it? Thomas, just 1 more request, I have added a question in this forum but not able to find any answers, can you please look into it for me..!!! The link is as: http://stackoverflow.com/questions/3777683/unable-to-set-focus-to-datepicker-using-attached-property-in-wpf
samar
Does it really need the `e` parameter ? It probably only needs *some* of its properties... Just pass those to your method
Thomas Levesque
This sounds like a good work around. Will try this out! Thanks for your time..!! :) Thomas, did you try out the other problem I had?? Please do check it out as I am really wanna make that working..!!
samar
I had a look at your other question, but I'm not able to answer it...
Thomas Levesque