c#wpf中的画笔图案(xaml-矢量)

c#wpf中的画笔图案(xaml-矢量),c#,wpf,drawing,brush,C#,Wpf,Drawing,Brush,我需要在画布上画一些画笔图案,比如Windows操作系统中的“画画”。 我需要“油刷”和“粉彩”。 据我所知,可以通过VisualBrush.Visual(带有向量路径的画布)实现 在我的应用程序中,我需要用模式(用户示例)在画布上画线,并用鼠标使用此模式进行绘制 你能帮助我在xaml中使用画笔模式(一步一步)和|或以编程方式画图吗?它可以是xaml中的矢量,也可以是使用的图像文件 现在,我使用画笔图案在xaml中绘制,但这不是画笔(就像在默认的绘画应用程序中一样): Drawing

我需要在画布上画一些画笔图案,比如Windows操作系统中的“画画”。 我需要“油刷”和“粉彩”。 据我所知,可以通过VisualBrush.Visual(带有向量路径的画布)实现


在我的应用程序中,我需要用模式(用户示例)在画布上画线,并用鼠标使用此模式进行绘制

你能帮助我在xaml中使用画笔模式(一步一步)和|或以编程方式画图吗?它可以是xaml中的矢量,也可以是使用的图像文件

现在,我使用画笔图案在xaml中绘制,但这不是画笔(就像在默认的绘画应用程序中一样):


DrawingBrush可能比VisualBrush简单:@Clemens可能是,但无论如何,我需要声明GeometryDrawing.Geometry。正如您所看到的,SVG或EPS是非常大的文件,在转换为xaml之后,它就不起作用了,因为画笔的默认大小非常大,我用这个画笔附加了xaml文件
<UserControl x:Class="DrawingToolbar.DTBrushParamsContainer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:DrawingToolbar"
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             mc:Ignorable="d" 
             d:DesignHeight="395" d:DesignWidth="500">

    <UserControl.Resources>
        <VisualBrush 
            x:Key="OilBrush" 
            TileMode="Tile" Viewport="0,0,10,10" 
            ViewportUnits="Absolute" Viewbox="0,0,10,10"    
            ViewboxUnits="Absolute">
            <VisualBrush.Visual>
                <Canvas Width="495.9968" Height="66.6656" ClipToBounds="True" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">

                </Canvas>
            </VisualBrush.Visual>
        </VisualBrush>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*" />
            <RowDefinition Height="55" />
        </Grid.RowDefinitions>


        <xctk:ColorCanvas x:Name="colorCanvas" Grid.Row="0" 
                          Background="Transparent"
                          Height="145" Width="237"
                          UsingAlphaChannel="False" Margin="0,27,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
        <Label Content="Цвет кисти:" HorizontalAlignment="Left" Height="27" VerticalAlignment="Top" Width="82"/>
        <Label Content="Толщина кисти:" HorizontalAlignment="Left" Height="27" VerticalAlignment="Top" Width="103" Margin="242,176,0,0"/>
        <Slider x:Name="brushSizeSlider" HorizontalAlignment="Left" Margin="242,203,0,0" VerticalAlignment="Top" Width="237" Maximum="100"/>
        <Label Content="Прозрачность цвета кисти:" HorizontalAlignment="Left" Height="27" VerticalAlignment="Top" Width="179" Margin="0,176,0,0"/>
        <Slider x:Name="transparencySlider" HorizontalAlignment="Left" Margin="0,203,0,0" VerticalAlignment="Top" Width="237" Maximum="255"/>
        <Label Content="Стиль кисти:" HorizontalAlignment="Left" Height="27" VerticalAlignment="Top" Width="103" Margin="242,0,0,0"/>
        <RadioButton x:Name="normalBrush_rb" Content="Обычная кисть" HorizontalAlignment="Left" Margin="242,27,0,0" VerticalAlignment="Top" IsChecked="True"/>
        <RadioButton x:Name="oilBrush_rb" Content="Кисть для масла" HorizontalAlignment="Left" Margin="242,77,0,0" VerticalAlignment="Top"/>
        <RadioButton x:Name="pastelBrush_rb" Content="Пастель" HorizontalAlignment="Left" Margin="242,127,0,0" VerticalAlignment="Top"/>

        <InkCanvas x:Name="normalBrush_ink" 
            Background="White"
            HorizontalAlignment="Left" Height="30" Margin="242,42,0,0" VerticalAlignment="Top" Width="248">

        </InkCanvas>

        <InkCanvas x:Name="oilBrush_ink" 
            Background="White"
            HorizontalAlignment="Left" Height="30" Margin="242,92,0,0" VerticalAlignment="Top" Width="248">

            <Line X1="10" X2="100" Y1="15" Y2="15" Visibility="Visible" StrokeThickness="5" Stroke="{StaticResource OilBrush}">
            </Line>

        </InkCanvas>

        <InkCanvas x:Name="pastelBrush_ink" 
            Background="White"
            HorizontalAlignment="Left" Height="30" Margin="242,142,0,0" VerticalAlignment="Top" Width="248"/>


    </Grid>
</UserControl>