RectangleGeometry with relative dimensions... how?

Posted by Padu Merloti on Stack Overflow See other posts from Stack Overflow or by Padu Merloti
Published on 2010-03-24T19:48:09Z Indexed on 2010/03/24 19:53 UTC
Read the original article Hit count: 239

Filed under:
|
|
|

I'm trying to replicate the nowadays so fashionable "reflex" effect on a controltemplate for buttons I'm creating.

The basic idea is to create a rectangle with a gradient fill from white to transparent and then clip some of that semi-transparent rectangle with a rectanglegeometry.

The problem is that I don't know how to define a relative rectangle geometry. I kind of worked around width by defining a large value (1000), but height is a problem. For example, it works good for buttons that have a 200 height, but doesn't do anything for smaller buttons.

Any ideas?

            <Rectangle RadiusX="5" RadiusY="5" StrokeThickness="1" Stroke="Transparent">
                <Rectangle.Fill>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,0.55">
                        <GradientStop Color="#66ffffff" Offset="0.0"  />
                        <GradientStop Color="Transparent" Offset="1.0" />
                    </LinearGradientBrush>
                </Rectangle.Fill>
                <Rectangle.Clip>
                    <RectangleGeometry Rect="0,0,1000,60" />
                </Rectangle.Clip>
            </Rectangle>

© Stack Overflow or respective owner

Related posts about wpf

Related posts about controltemplate