फिर भी इष्टतम नहीं लेकिन कैसे एक 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();
}
}
स्रोत
2011-08-09 11:02:52
सीमा एक नियंत्रण नहीं है लेकिन एक फ्रेमवर्क एलिमेंट है। गुणों के साथ इसे हल करने में बेहतर देखो। –
आपका क्या मतलब है? – Jon
यहां सुझाए गए समाधानों में क्या गलत है? http://stackoverflow.com/questions/1048137/ –