Все еще не оптимально, но как насчет использования решения по ссылке Мэттом Гамильтоном в качестве VisualBrush
Сравнения с использованием VisualBrush
с пунктирными Rectangle
и SolidColorBrush
<Border BorderThickness="3,2,1,0" CornerRadius="10">
<Border.BorderBrush>
<VisualBrush>
<VisualBrush.Visual>
<Rectangle StrokeDashArray="1.0 1.0"
Stroke="Red"
StrokeThickness="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}},
Path=BorderThickness,
Converter={StaticResource ThicknessMaxConverter}}"
RadiusX="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=CornerRadius.TopRight}"
RadiusY="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=CornerRadius.BottomLeft}"
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}"/>
</VisualBrush.Visual>
</VisualBrush>
</Border.BorderBrush>
</Border>
ThicknessMaxConverter
public class ThicknessMaxConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Thickness thickness = (Thickness)value;
double horizontalMax = Math.Max(thickness.Left, thickness.Right);
double verticalMax = Math.Max(thickness.Top, thickness.Bottom);
return Math.Max(horizontalMax, verticalMax);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}