c# - WPF FrameworkElement Mouse Click issue -
in wpf app have bunch of customcontrols inside grid. processing mouse clicks on them use mouseleftbuttondown
event of grid , in event handler check customcontrol clicked:
private void grid_mouseleftbuttondown(object sender, mousebuttoneventargs e) { frameworkelement fesourcecomm = e.source frameworkelement; mycustomcontrol scurrentcomm = new mycustomcontrol(); try { scurrentcomm = (mycustomcontrol)fesourcecomm; } catch (exception) { ...
the problem appeared when placed customcontrols in usercontrol , inside grid. in case approach doesn't work.
checked type of click source in each case e.source.gettype().tostring();
, following results:
when there no problem (in case put customcontrols in grid without usercontrol)
myprojectnamespace.mycustomcontrol
when put customcontrols in usercontrol , in grid
myprojectnamespace.usercontrols.myusercontrolname
when put customcontrols in usercontrol , in grid , load usercontrol external file xamlreader.load
system.windows.controls.usercontrol
so, question:
how make customcontrols vizible e.source
when inside of usercontrol?
e.originalsource
tell specific element click happened on. if not customcontrol, walk parent chain of originalsource
until find customcontrol
Comments
Post a Comment