在 Silverlight5 中如何从 XAML 引用事物类:
xmlns:UserControls="clr-namespace:xyz.ClientApp.UserControls"
public class Thing : ContextMenu, IDisposable
{
public void Dispose()
{
MethodInfo infos = typeof(ContextMenu).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(a => a.Name.Equals("HandleRootVisualMouseMove")).FirstOrDefault();
Delegate handler = Delegate.CreateDelegate(typeof(MouseEventHandler), this, infos);
EventInfo info = System.Windows.Application.Current.RootVisual.GetType().GetEvent("MouseMove");
info.RemoveEventHandler(System.Windows.Application.Current.RootVisual, handler);
}
}
我正在尝试在此处修复 ContextMenuService 中的错误