basically want lay out visual elements can change content according location laid. want in wpf might able suggest general algorithm without knowing wpf.
example: consider wrappanel
contains label
s hold text. when label
laid wrappanel
@ beginning of new row leading white spaces removed text. indeed make label
shorter.
the think knows such label
laid wrapppanel
layouting. 1 approach code custom panel
overrides measureoverride
, arrangeoverride
, change label
s inside measureoverride
before calling measure
on label
. don't because:
- it ugly hack (
panel
,measureoverride
,arrangeoveride
should position children not change them). - i'm not sure think if changed
label
insidemeasureoverride
label
cause layout updated in response lead (recursive) callmeasureoverride
(=> infinite loop).
so please suggest right design scenario. how should this? 1 comes mind to:
- have regular
wrappanel
. - every times
width
orheight
changed or children changed (its children might repositioned) update children beforemeasureoverride
,arrangeoverride
called. - during process of updating children (2.) no call
measure
orarrange
ofwrappanel
can made. question: how temporally inhibit such calls ?
before suggest use richtextbox
or textblock
deal white space @ beginning of lines note label
s , white spaces example - little more complicated. if know how solve 'label
s , white spaces' correctly i'll know how solve real problem too.
if want know why need have on question create guitar chords editor in wpf , h.b.'s answer.
Comments
Post a Comment