public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is LegendLocation)) return null;
var legendLocation = (LegendLocation) value;
var horAlignment = string.IsNullOrEmpty((string) parameter) || ((string) parameter).StartsWith("H");
if (horAlignment)
switch (legendLocation)
{
case LegendLocation.TopLeft:
case LegendLocation.BottomLeft:
return HorizontalAlignment.Left;
case LegendLocation.TopRight:
case LegendLocation.BottomRight:
return HorizontalAlignment.Right;
}
else
switch (legendLocation)
{
case LegendLocation.TopLeft:
case LegendLocation.TopRight:
return VerticalAlignment.Top;
case LegendLocation.BottomLeft:
case LegendLocation.BottomRight:
return VerticalAlignment.Bottom;
}
return null;
}