locked
How to bind to a clipping RectangleGeometry width and height in a winstore app

    Question

  • I'm trying to create a control which is a Canvas containing some procedurally generated elements, and I'd like to clip them to the visible area of the Canvas. I would like to bind its width and height to the control width and height via a template binding, but it appears that a RectangleGeometry only presents the "Rect" property, which is a string containing the bounding box position and size.

    My question is essentially identical to this one:

    http://social.msdn.microsoft.com/Forums/en-US/8ebbd499-fe17-4a03-96b5-5e27e343b62c/rectanglegeometry-binding-width-height-and-radius?forum=wpf

    except that windows store apps don't get IMultiValueConverter, according to this:

    http://social.msdn.microsoft.com/Forums/windowsapps/en-US/41ab4dd5-cbc8-4528-bc80-d3d7d05a02af/no-imultivalueconverter-interface

    Is there something similar that I'm missing, or a different way to do it?

    Also, I've been unable to figure out how to verify my account to become allowed to post links and not get the "Body text cannot contain images or links until we are able to verify your account" message.

    Saturday, March 8, 2014 6:04 AM

Answers

All replies

  • Take a look at using a value converter to provide a Rect.

    For account verification issues check out the Forums Issues (not product support) forum.

    Saturday, March 8, 2014 3:38 PM
    Owner
  • As far as I can tell, that approach doesn't work because a ValueConverter only gets access to one of the 4 properties required to create a Rect at a time. 

    I cannot convert a Width to a Rect, because the Value Converter wouldn't know the Height, X, or Y. This is why the answer I posted uses an IMultiValueConverter, which can do that, but like I said, there's no IMultiValueConverter in winRT.

    Monday, March 10, 2014 3:11 AM
  • Don't convert from Width,Height to rect. Convert from Canvas to Rect.

    --Rob

    Wednesday, March 12, 2014 1:25 AM
    Owner