1

我有以下 XAML:

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <DockPanel Margin="5">
  <Path Stroke="Black" StrokeThickness="1" Fill="White" DockPanel.Dock="Left" VerticalAlignment="Center">
      <Path.Data>
          <GeometryGroup>
              <LineGeometry StartPoint="10,0" EndPoint="0,10" />
              <LineGeometry StartPoint="0,10" EndPoint="10,20" />
          </GeometryGroup>
      </Path.Data>
    </Path>
    <Rectangle Stroke="Black" RadiusX="10" RadiusY="10"/>
  </DockPanel>
</Page>

它就像一个讲话泡泡。但是我希望两者结合的部分是白色的或没有任何中风。

在此处输入图像描述

4

2 回答 2

1

不是很聪明,但也许足够了:

<DockPanel Margin="5">
    <Path Stroke="Black" StrokeThickness="1"
          Fill="White" DockPanel.Dock="Left" VerticalAlignment="Center"
          Panel.ZIndex="1" Margin="0,0,-1,0" Data="M10,0 L0,10 10,20"/>
    <Rectangle Stroke="Black" RadiusX="10" RadiusY="10"/>
</DockPanel>

更好的解决方案可能是CombinedGeometry从路径和矩形创建一个。

于 2013-08-21T16:41:10.697 回答
0

如果您有权访问 Blend,您可以使用该Callout控件,这正是您想要的。它位于此程序集中:

C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.0\Libraries\Microsoft.Expression.Drawing.dll

并像这样使用:

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>

        <ed:Callout AnchorPoint="-0.061,0.716" CalloutStyle="RoundedRectangle" Content="Callout" Fill="#FFF4F4F5" FontSize="14.667" HorizontalAlignment="Left" Height="109" Margin="61,78,0,0" Stroke="Black" VerticalAlignment="Top" Width="375"/>

    </Grid>
</Window>

截屏

编辑:如果您有 Blend(对于 VS 2012),您可以轻松地自己绘制一条看起来像标注的路径。

例子:

<Path Data="M110.029,0.5 L305.895,0.5 C314.17927,0.50000358 320.895,7.2157323 320.895,15.500005 L320.895,144.202 C320.895,152.48627 314.17927,159.202 305.895,159.202 L110.029,159.202 C101.74473,159.202 95.028999,152.48627 95.029,144.202 L95.029,119.139 0.5,94.029644 94.530329,44.776012 95.029,69.723011 95.029,15.500005 C95.028999,7.2157323 101.74473,0.50000358 110.029,0.5 z" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="159.702" Margin="122.366,45.642,0,0" Stretch="Fill" Stroke="Black" VerticalAlignment="Top" Width="321.395"/>
于 2013-08-21T14:36:34.357 回答