[SOLVED] How to fix anchor/clipping problems when scaling a GridView
-
I implemented a "zoom" feature by allowing to adjust the
scaleproperty of aGridViewthat wraps at the right edge:GridView { //... scale: zoomLevel transformOrigin: Item.TopLeft anchors.top: commandArea.bottom anchors.left: parent.left anchors.right: parent.right anchors.bottom: statusArea.top }However, although the anchors are constant, when I zoom in, the content exceeds the right border and when I zoom out, the content is clipped above the bottom border.
I was able to fix the issues using the following properties:
anchors.rightMargin: (scale - 1.0) * width anchors.bottomMargin: -(height * (1.0 - scale))However, I get "binding loop" errors related to these two lines in the console every time I adjust the zoom level. While it seems to work anyway, the errors indicate that it's a bit of a hack... Is there a better way to do this? If not, can I just ignore the errors?
-
I implemented a "zoom" feature by allowing to adjust the
scaleproperty of aGridViewthat wraps at the right edge:GridView { //... scale: zoomLevel transformOrigin: Item.TopLeft anchors.top: commandArea.bottom anchors.left: parent.left anchors.right: parent.right anchors.bottom: statusArea.top }However, although the anchors are constant, when I zoom in, the content exceeds the right border and when I zoom out, the content is clipped above the bottom border.
I was able to fix the issues using the following properties:
anchors.rightMargin: (scale - 1.0) * width anchors.bottomMargin: -(height * (1.0 - scale))However, I get "binding loop" errors related to these two lines in the console every time I adjust the zoom level. While it seems to work anyway, the errors indicate that it's a bit of a hack... Is there a better way to do this? If not, can I just ignore the errors?
Hi @pholz,
I suspect this is because thewidthofGridViewis binded torightMargin(right side spacing) of theGridViewitself. So when thewidthofGridViewchanges it affects therightMarginwhich in turn will affect thewidthofGridView(it will become thinner) and thus this goes on (loop). -
Hi @pholz,
I suspect this is because thewidthofGridViewis binded torightMargin(right side spacing) of theGridViewitself. So when thewidthofGridViewchanges it affects therightMarginwhich in turn will affect thewidthofGridView(it will become thinner) and thus this goes on (loop).