Turns out there's a very simple solution.
By adding a IValueConverter and using the converter in the binding expression, but ignoring the culture argument, the formatting works perfectly.
You will need one converter (if you don't make it take arguments) for each different format.
Converter (removed the attribute from the sample):
public class DateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
DateTime date = (DateTime)value;
return date.ToShortDateString();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
string strValue = value as string;
DateTime resultDateTime;
if (DateTime.TryParse(strValue, out resultDateTime))
{
return resultDateTime;
}
return DependencyProperty.UnsetValue;
}
}
namespace
xmlns:conv="clr-namespace:Sjofartsverket.LotsPDA20.Client.Converters"
resource
<conv:DateConverter x:Key="dateConverter" />
Binding expression:
<TextBlock Text="{Binding StartDate, Converter={StaticResource dateConverter}}"
Result:
The date is rendered in the correct culture.