Following Increase StrokeThickness but maintain dimensions of Path, is it possible to do the opposite? keeping only the outer stroke. Is there a way to exclude the self geometry?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You may also clip the Path by its own geometry, but use a CombinedGeometry
with a large enough outer RectangleGeometry and an excluded inner geometry, provided by the Path's Data
:
<Path ...>
<Path.Clip>
<CombinedGeometry
GeometryCombineMode="Exclude"
Geometry2="{Binding Data, RelativeSource={RelativeSource AncestorType=Path}}">
<CombinedGeometry.Geometry1>
<RectangleGeometry Rect="-1000,-1000,2000,2000"/>
</CombinedGeometry.Geometry1>
</CombinedGeometry>
</Path.Clip>
</Path>
Alternatively, you may perhaps draw a second, filled Path with the same geometry on top of the first one. You need to make sure both are aligned identically.
<Path x:Name="path" ...>
<Path Fill="White" Data="{Binding Data, ElementName=path}"/>