通过C#设置InkCanvas背景DrawingBrush

时间:2016-06-25 11:21:25

标签: c# wpf visual-studio canvas inkcanvas

我想通过C#设置以下XAML属性:

<InkCanvas.Background>
                <DrawingBrush Stretch="None" TileMode="Tile" Viewport="0,0,2,2" ViewportUnits="Absolute">
                    <DrawingBrush.Drawing>
                        <DrawingGroup>
                            <GeometryDrawing Brush="White">
                                <GeometryDrawing.Geometry>
                                    <RectangleGeometry Rect="0,0,2,2" />
                                </GeometryDrawing.Geometry>
                            </GeometryDrawing>
                            <GeometryDrawing Brush="#FFE3E3E3">
                                <GeometryDrawing.Geometry>
                                    <GeometryGroup>
                                        <RectangleGeometry Rect="0,0,1,1" />
                                        <RectangleGeometry Rect="1,1,1,1" />
                                    </GeometryGroup>
                                </GeometryDrawing.Geometry>
                            </GeometryDrawing>
                        </DrawingGroup>
                    </DrawingBrush.Drawing>
                </DrawingBrush>
            </InkCanvas.Background>

我应该怎么做?

1 个答案:

答案 0 :(得分:1)

我自己找到了解决方案,并将其留给其他人,面对同样的问题。

http://www.c-sharpcorner.com/uploadfile/mahesh/wpf-drawing-brush/几乎就是我在寻找的东西。