Getting the width of a path drawn on a XAML canvas -


i'm drawing canvas programmatically, given bunch of path data somewhere else , adding canvas as

// done more elaborately, pathfigurecollection figures = getpathfigurecollection();  var path = new path {     data = new pathgeometry { figures = figures },     fill = getfill(),     stroke = getstroke(),     strokethickness = getthickness() }; mycanvas.children.add(path); 

now, have canvas in scrollviewer, want make sure can scroll way reveal entire path (actually paths - have several, generated same way) no further. tried this:

var drawingwidth = mycanvas.children                        .oftype<frameworkelement>()                        .max(e => canvas.getleft(e) + e.actualwidth); mycanvas.width = drawingwidth; 

this works other elements (the drawing has few text blocks , ellipses), paths both canvas.getleft(e) , e.actualwith (as other things tried e.rendersize.width , e.desiredsize.with) return 0. since element extends farthest right path, results in canvas small.

how width of path elements too?

ha, found it!

rewriting linq query loop, cast paths path, , use path.data.bounds.right right edge of element.** might able convert code linq query know want (i find them more readable stateful loops...).

i found when i, after having perused link provided marke where, side note, stated that

if design requirements allow more rough approximates, find cubic bezier curves contained within control points.

so, if find right-most control point of path figures in path, home. intellisense did rest of job me :)


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -