none
WPF GeometryGroup : How to make Geometry objects snap to device pixels ? RRS feed

  • 问题

  • Hi all,

    I found that the Geometry objects in the shape Path do not snap to device pixels,

    How can I fix this problem ?

    code like this:

    <Canvas SnapsToDevicePixels="True" >
       <Path Stroke="Black" StrokeThickness="1" >
          <Path.Data>
             <GeometryGroup>
                <RectangleGeometry Rect="50,50 100 100" />
                <RectangleGeometry Rect="150,50 100 100" />
             </GeometryGroup>
          </Path.Data>
       </Path>
    </Canvas>

    I use Path to display RectangleGeometry instead of using Shapes.Rectangle directly, because when applying ScaleTransforms, stroke thickness remains invariant, see this:

    invariant-stroke-thickness-of-path-regardless-of-the-scale 

    Thanks!

    Fang He


    • 已编辑 Fang He 2012年8月27日 13:26
    2012年8月27日 13:17

答案

  • 试试这个属性:

    RenderOptions.EdgeMode="Aliased"


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • 已标记为答案 Fang He 2012年9月1日 17:16
    2012年8月28日 8:17
    版主