wpf - Dynamic complex Tooltip -
i want generate tool tip dynamically since tooltip has contain grid dynamic number of columns.
how do ?
you can create new popup , simulate tooltip popup.
you have handle 2 events: mouseenter, mouseleave.
on mouse enter can have timer open popup after x seconds:
private void canvas_mouseenter(object sender, system.windows.input.mouseeventargs e) { timer = new timer(500); timer.elapsed += timer_elapsed; timer.enabled = true; }
and on mouse leave cancel timer:
private void canvas_mouseleave(object sender, system.windows.input.mouseeventargs e) { timer.elapsed -= timer_elapsed; timer = null; }
when timer elapses, you'll use dispatcher open popup:
void timer_elapsed(object sender, elapsedeventargs e) { dispatcher.begininvoke(dispatcherpriority.normal, new ooldelegate(opentooltip), true); }
the open tooltip method open popup:
public void opentooltip(bool isopen) { popup.isopen = isopen; popup.lostfocus += popup_lostfocus; }
and can close when popup lost focus
hope can help
Comments
Post a Comment