c# - How to detect if the mouse is directly over an object type in WPF -


i need detect (true or false) if mouse on specific type of object. there 1 data template many objects use. not need instance of object, need detect if mouse above type of element on ui.

it along lines of:

if(mouse.directlyover == storageelementwrapper) { ... } 

edit: error using type variable

it's important note directlyover find inside element rather element you're looking for. use property, you'd want @ parent tree of directlyover element. along these lines, findancestororself coming this blog post:

if (util.findancestororself<storageelementwrapper>((dependencyobject)mouse.directlyover) != null) { ... } 

or if have code references storageelementwrappers, (in example, in collection named mywrappers) , derive uielement, better approach, using ismouseover property:

if (mywrappers.any(x => x.ismouseover))     // 

Comments