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


  • 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:


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


    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


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
  • 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.


    Wednesday, March 12, 2014 1:25 AM