Hi gaganeti,
Sounds like you should pick up your .NET/WPF book again :-)
Also a good advice: Learn what VS is telling you in the error messages, try to understand what the various messages mean (sometimes obviouse, sometimes not).
So:
item.IsSelectionActive = ...
won't work because you try to access a property without a public setter - so no way to set it like this (you can circumvent this by reflection, but don't, the class designer very likely knew what he was doing when he limited Access to this property - I'd guess it's "calculated" on call).
Regarding Event handling: I don't understand what you realy want. "Access a event-handler"?. What you want? HANDLE the Event or RAISE the Event, or ACCESS just the handler (which is a normal method, so just make it public). Always the same problems when talking about .NET events because everyone is mixing up the terms.
So from your example I would guess you want to ACCESS the handler method itself. So your code structure should look something like this:
class A
{
TreeView treeview = new TreeView();
public A()
{
treeview.MouseLeftButtonUp += treeview_MouseLeftButtonUp;
}
public void treeview_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { }
}
class B
{
TreeView treeview = new TreeView();
public B(A a)
{
treeview.MouseLeftButtonUp += a.treeview_MouseLeftButtonUp;
}
}
Is this what you want?
Anyway this is quite a strange pattern and I think you should consider some design-change. This approach would be against all good OOP principles in my opinion.
Sorry if I have miss-understood you (English is not my native language...).
Kind regards
Johannes