WPF使用Expression Design设计图形

1.将画好的图形通过菜单导出成WPF xaml格式。

  

2.导出的文件就可以直接在WPF程序中使用了。

  这里导出的DrawingBrush,

  

<?xml version="1.0" encoding="utf-8"?>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <DrawingBrush x:Key="Layer_1" Stretch="Uniform">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 457.573,312.171L 453.463,299.376L 462.222,289.183L 452.266,280.156L 454.755,266.949L 441.619,264.11L 437.171,251.428L 424.375,255.537L 414.183,246.778L 405.156,256.735L 391.949,254.245L 389.11,267.381L 376.428,271.829L 380.537,284.625L 371.778,294.817L 381.735,303.844L 379.245,317.051L 392.381,319.89L 396.829,332.573L 409.625,328.463L 419.817,337.222L 428.844,327.266L 442.051,329.755L 444.89,316.619L 457.573,312.171 Z ">
                        <GeometryDrawing.Pen>
                            <Pen Thickness="2" LineJoin="Round" Brush="#FFFFFFFF"/>
                        </GeometryDrawing.Pen>
                    </GeometryDrawing>
                    <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 386.038,290.135C 387.224,272.155 402.232,258.507 419.559,259.651C 436.886,260.794 449.97,276.296 448.784,294.276C 447.597,312.255 432.589,325.904 415.262,324.76C 397.935,323.617 384.851,308.115 386.038,290.135 Z "/>
                    <GeometryDrawing Brush="#FF1D82DA" Geometry="F1 M 385.031,290.236L 385.038,290.069L 385.038,290.069C 385.812,281.515 389.847,272.616 396.087,266.941C 402.327,261.267 411.357,258.285 419.628,258.613L 419.628,258.613C 427.87,259.374 436.429,263.517 441.869,269.963C 447.31,276.408 450.14,285.761 449.784,294.342L 449.784,294.342C 449.01,302.896 444.974,311.795 438.734,317.47C 432.494,323.144 423.464,326.126 415.194,325.798L 415.194,325.798C 406.952,325.036 398.392,320.894 392.952,314.448C 387.512,308.003 384.681,298.65 385.038,290.069L 385.041,290.034L 387.006,290.166L 387.003,290.199L 387.003,290.199C 386.668,298.259 389.327,307.044 394.437,313.098C 399.547,319.152 407.587,323.043 415.328,323.758L 415.328,323.758C 423.097,324.066 431.578,321.266 437.439,315.936C 443.301,310.606 447.091,302.246 447.818,294.212L 447.818,294.212C 448.153,286.152 445.494,277.367 440.384,271.313C 435.274,265.259 427.235,261.368 419.493,260.653L 419.493,260.653C 411.724,260.344 403.243,263.145 397.382,268.475C 391.521,273.805 387.73,282.164 387.003,290.199L 386.997,290.356L 385.031,290.236 Z "/>
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
</ResourceDictionary>
View Code

复制DrawingBrush节点,到所要填补的形状节点中,通过形状节点.Fill属性进行使用。

  

        <Ellipse Width="80" Height="80" HorizontalAlignment="Right" VerticalAlignment="Bottom">
            <Ellipse.Fill>
                <DrawingBrush Stretch="Uniform">
                    <DrawingBrush.Drawing>
                        <DrawingGroup>
                            <DrawingGroup.Children>
                                <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 457.573,312.171L 453.463,299.376L 462.222,289.183L 452.266,280.156L 454.755,266.949L 441.619,264.11L 437.171,251.428L 424.375,255.537L 414.183,246.778L 405.156,256.735L 391.949,254.245L 389.11,267.381L 376.428,271.829L 380.537,284.625L 371.778,294.817L 381.735,303.844L 379.245,317.051L 392.381,319.89L 396.829,332.573L 409.625,328.463L 419.817,337.222L 428.844,327.266L 442.051,329.755L 444.89,316.619L 457.573,312.171 Z ">
                                    <GeometryDrawing.Pen>
                                        <Pen Thickness="2" LineJoin="Round" Brush="#FFFFFFFF"/>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                                <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 386.038,290.135C 387.224,272.155 402.232,258.507 419.559,259.651C 436.886,260.794 449.97,276.296 448.784,294.276C 447.597,312.255 432.589,325.904 415.262,324.76C 397.935,323.617 384.851,308.115 386.038,290.135 Z "/>
                                <GeometryDrawing Brush="#FF1D82DA" Geometry="F1 M 385.031,290.236L 385.038,290.069L 385.038,290.069C 385.812,281.515 389.847,272.616 396.087,266.941C 402.327,261.267 411.357,258.285 419.628,258.613L 419.628,258.613C 427.87,259.374 436.429,263.517 441.869,269.963C 447.31,276.408 450.14,285.761 449.784,294.342L 449.784,294.342C 449.01,302.896 444.974,311.795 438.734,317.47C 432.494,323.144 423.464,326.126 415.194,325.798L 415.194,325.798C 406.952,325.036 398.392,320.894 392.952,314.448C 387.512,308.003 384.681,298.65 385.038,290.069L 385.041,290.034L 387.006,290.166L 387.003,290.199L 387.003,290.199C 386.668,298.259 389.327,307.044 394.437,313.098C 399.547,319.152 407.587,323.043 415.328,323.758L 415.328,323.758C 423.097,324.066 431.578,321.266 437.439,315.936C 443.301,310.606 447.091,302.246 447.818,294.212L 447.818,294.212C 448.153,286.152 445.494,277.367 440.384,271.313C 435.274,265.259 427.235,261.368 419.493,260.653L 419.493,260.653C 411.724,260.344 403.243,263.145 397.382,268.475C 391.521,273.805 387.73,282.164 387.003,290.199L 386.997,290.356L 385.031,290.236 Z "/>
                            </DrawingGroup.Children>
                        </DrawingGroup>
                    </DrawingBrush.Drawing>
                </DrawingBrush>
            </Ellipse.Fill>
        </Ellipse>
View Code
原文地址:https://www.cnblogs.com/xcong/p/3398208.html