Вы можете создать этот треугольник как OpacityMask
или Clip
вашего изображения.
например,
<Image.Clip>
<PathGeometry>
<PathFigure StartPoint="0,10">
<LineSegment Point="20,0" />
<LineSegment Point="20,20" />
</PathFigure>
</PathGeometry>
</Image.Clip>
<Image.OpacityMask>
<VisualBrush Stretch="None" AlignmentX="Left" AlignmentY="Top">
<VisualBrush.Visual>
<Path Fill="Black">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="0,10" IsClosed="True" IsFilled="True">
<LineSegment Point="20,0" />
<LineSegment Point="20,20" />
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
</VisualBrush.Visual>
</VisualBrush>
</Image.OpacityMask>
Вы можете обрезать пространство изображения, используя поле:
<Image.Margin>
<Binding Path="Clip.Bounds" RelativeSource="{RelativeSource Self}">
<Binding.Converter>
<vc:BoundsToMarginConverter />
</Binding.Converter>
</Binding>
</Image.Margin>
Конвертер:
public class BoundsToMarginConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Rect input = (Rect)value;
return new Thickness()
{
Left = -input.Left,
Right = -input.Right,
Top = -input.Top,
Bottom = -input.Bottom,
};
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
Это вряд ли хорошее решение, но оно работает ...