I had create a extend method for WPF ListBox control for treat ListBox SelectedItem, but I want turn this better, I want show my extend method when I type listBox1.SelectedItem.MyExtendMethod();
I can change my method for public static void MyExtendMethod(this object item)
, but it will show for all 'object'
What can I do for this extend method just show for ListBox>objects? this is possible?
Well, no. Since extension methods know nothing about the call site, you can't restrict one to ListBox.SelectedItem
. You're probably better off just applying it to ListBox
.