c# - WPF richTextBox cant identify as UIElement -
i have following code attaches adorner
s uielement
s have on canvas
.
private void slidecanvas_previewmouseleftbuttondown(object sender, mousebuttoneventargs e) { { selected = false; if (selectedelement != null) { alayer.remove(alayer.getadorners(selectedelement)[0]); selectedelement = null; } } if (e.source != slidecanvas) { _isdown = true; _startpoint = e.getposition(slidecanvas); selectedelement = e.source uielement; _originalleft = canvas.getleft(selectedelement); _originaltop = canvas.gettop(selectedelement); alayer = adornerlayer.getadornerlayer(selectedelement); alayer.add(new resizingadorner(selectedelement)); selected = true; e.handled = true; } }
for reason though when click on richtextbox
during runtime program crashes richtextbox
not found e.source
uielement
.
selectedelement
null
.
can tell me why , give me work around please?
apparently e.source
document
of richtextbox clicked on. flowdocument
, not derived uielement
.
you may access richtextbox flowdocument's parent
property.
if (e.source flowdocument) { selectedelement = ((flowdocument)e.source).parent uielement; } else { selectedelement = e.source uielement; }
Comments
Post a Comment