Click here to Skip to main content
15,917,061 members
Home / Discussions / C#
   

C#

 
AnswerRe: post and manipulate result JSON WebService Pin
Garth J Lancaster25-Jan-16 13:33
professionalGarth J Lancaster25-Jan-16 13:33 
GeneralRe: post and manipulate result JSON WebService Pin
Member 1228688326-Jan-16 14:22
Member 1228688326-Jan-16 14:22 
GeneralRe: post and manipulate result JSON WebService Pin
Garth J Lancaster26-Jan-16 14:31
professionalGarth J Lancaster26-Jan-16 14:31 
QuestionRe-Assignable Keyboard Shortcuts Pin
Eiredrake25-Jan-16 11:05
Eiredrake25-Jan-16 11:05 
AnswerRe: Re-Assignable Keyboard Shortcuts Pin
John Torjo25-Jan-16 23:20
professionalJohn Torjo25-Jan-16 23:20 
AnswerRe: Re-Assignable Keyboard Shortcuts Pin
Pete O'Hanlon26-Jan-16 0:09
mvePete O'Hanlon26-Jan-16 0:09 
GeneralRe: Re-Assignable Keyboard Shortcuts Pin
Richard MacCutchan26-Jan-16 0:28
mveRichard MacCutchan26-Jan-16 0:28 
GeneralRe: Re-Assignable Keyboard Shortcuts Pin
Pete O'Hanlon26-Jan-16 0:52
mvePete O'Hanlon26-Jan-16 0:52 
QuestionData disappears on postback Pin
Carl Cummings25-Jan-16 7:21
Carl Cummings25-Jan-16 7:21 
AnswerRe: Data disappears on postback Pin
Richard Deeming25-Jan-16 8:51
mveRichard Deeming25-Jan-16 8:51 
QuestionHow to use WeakEventManager with reflection Pin
Kenneth Haugland23-Jan-16 23:21
mvaKenneth Haugland23-Jan-16 23:21 
SuggestionRe: How to use WeakEventManager with reflection Pin
Kornfeld Eliyahu Peter24-Jan-16 1:18
professionalKornfeld Eliyahu Peter24-Jan-16 1:18 
GeneralRe: How to use WeakEventManager with reflection Pin
Sascha Lefèvre24-Jan-16 1:34
professionalSascha Lefèvre24-Jan-16 1:34 
GeneralRe: How to use WeakEventManager with reflection Pin
Kornfeld Eliyahu Peter24-Jan-16 1:38
professionalKornfeld Eliyahu Peter24-Jan-16 1:38 
GeneralRe: How to use WeakEventManager with reflection Pin
Sascha Lefèvre24-Jan-16 1:42
professionalSascha Lefèvre24-Jan-16 1:42 
GeneralRe: How to use WeakEventManager with reflection Pin
Kenneth Haugland24-Jan-16 3:25
mvaKenneth Haugland24-Jan-16 3:25 
GeneralRe: How to use WeakEventManager with reflection Pin
Kornfeld Eliyahu Peter24-Jan-16 3:42
professionalKornfeld Eliyahu Peter24-Jan-16 3:42 
GeneralRe: How to use WeakEventManager with reflection Pin
Kenneth Haugland24-Jan-16 3:47
mvaKenneth Haugland24-Jan-16 3:47 
AnswerRe: How to use WeakEventManager with reflection Pin
Sascha Lefèvre24-Jan-16 2:37
professionalSascha Lefèvre24-Jan-16 2:37 
I'm not familiar with WPF and PropertyDescriptor, so this might not be all you need but I think it'll get you a step further. I simplified it a bit so that I could test it in a new WPF-project. Note that you need a generic EventHandler for the AddHandler(..)-call and that you need to provide the name of the event there, not the name of the property:
C#
public MainWindow()
{
    InitializeComponent();

    object sender = this;
    WeakReference _sender = new WeakReference(sender);
    EventHandler<EventArgs> handler = (s, e) => this.Title += ".";
    string eventName = "MouseMove";

    Type unboundWEMType = typeof(WeakEventManager<,>);
    Type[] typeArgs = { _sender.Target.GetType(), typeof(EventArgs) };
    Type constructedWEMType = unboundWEMType.MakeGenericType(typeArgs);
    MethodInfo addHandlerMethod = constructedWEMType.GetMethod("AddHandler");
    addHandlerMethod.Invoke(null, new object[] { _sender.Target, eventName, handler });
}
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

GeneralRe: How to use WeakEventManager with reflection Pin
Kenneth Haugland24-Jan-16 3:11
mvaKenneth Haugland24-Jan-16 3:11 
GeneralRe: How to use WeakEventManager with reflection Pin
Sascha Lefèvre24-Jan-16 4:33
professionalSascha Lefèvre24-Jan-16 4:33 
GeneralRe: How to use WeakEventManager with reflection Pin
Kenneth Haugland24-Jan-16 4:45
mvaKenneth Haugland24-Jan-16 4:45 
GeneralRe: How to use WeakEventManager with reflection Pin
Sascha Lefèvre24-Jan-16 6:14
professionalSascha Lefèvre24-Jan-16 6:14 
GeneralRe: How to use WeakEventManager with reflection Pin
Kenneth Haugland24-Jan-16 17:34
mvaKenneth Haugland24-Jan-16 17:34 
GeneralRe: How to use WeakEventManager with reflection Pin
Kenneth Haugland24-Jan-16 22:45
mvaKenneth Haugland24-Jan-16 22:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.