Hi, I need to make some colmuns aligment to left based on the value of other column (language code e.g fi-FI, en-US, ar-SA -> right alignment).
Can I do it with binding or do I have to do it in code behind. I have a lot of rows (thousands) so I can not loop them in code behind or grid gets really slow?
Is it posible to do some kind of fast value converter? I know I can create style like
<Style TargetType="{x:Type igEditors:XamDateTimeEditor}" >
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
</Style>
Br,
Mauri Korhonen
Hello Mauri,
I have been looking into your requirement and I can suggest you create a style for the XamDateTimeEditor with a Converter like this one:
<local:StringToAlignmentConverter x:Key="con" />
<Style TargetType="{x:Type igEditors:XamDateTimeEditor}">
<Setter Property="HorizontalContentAlignment" Value="{Binding Path=Record.DataItem.Currency, ConverterCulture=en-US, RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Converter={StaticResource con}}" />
where:
Currency is the property containing the language code and
public class StringToAlignmentConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
if (value.ToString() == "ar-SA")
return HorizontalAlignment.Right;
}
else return HorizontalAlignment.Left;
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();
Please let me know, if you require any further assistance on the matter.
Really NICE! This is exactly what I meant and was looking for. I got it implemented based on this example and works really well!! Thanks :D Job well done...
Mauri