Hi guys,
I've set up some columns which are of Decimal data type with a data format string which converts these decimals values to a percentage between 0 - 100% ie. DataFormatString = "{0.0.00\\%}". The problem I am having is a few of these rows do not need to have the data format string on them, they should be left as they are. I've had a look at conditional formatting with Converters with the ContentStringFormat but can't get this to work (I believe because the data type is decimal?). I am using the decimal type because this helps with validation (only numerics). Otherwise, what's the best method to implement this?
Thanks!
Tim.
This is the code I used for the converter:
XAML
Binding Path=Period is a <BindingList> of Decimals so 'object value' returns an array of objects, which I have to extract. Basically my goal is to overwrite (or bypass) the DataFormatString in the GridViewDataColumn for a few rows - if this is possible.
Converter Class
I've set up some columns which are of Decimal data type with a data format string which converts these decimals values to a percentage between 0 - 100% ie. DataFormatString = "{0.0.00\\%}". The problem I am having is a few of these rows do not need to have the data format string on them, they should be left as they are. I've had a look at conditional formatting with Converters with the ContentStringFormat but can't get this to work (I believe because the data type is decimal?). I am using the decimal type because this helps with validation (only numerics). Otherwise, what's the best method to implement this?
Thanks!
Tim.
This is the code I used for the converter:
XAML
<
telerikGrid:RadGridView.Resources>
<Client:ValueConverter x:Key="ValueConverter"/>
<Style TargetType="{x:Type telerik:GridViewCell }">
<Setter Property="ContentStringFormat" Value="{Binding Path=Period,Converter={StaticResource ValueConverter}}"/>
</Style>
</telerikGrid:RadGridView.Resources>
Binding Path=Period is a <BindingList> of Decimals so 'object value' returns an array of objects, which I have to extract. Basically my goal is to overwrite (or bypass) the DataFormatString in the GridViewDataColumn for a few rows - if this is possible.
Converter Class
public
object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
//if (a[0] > 100)
return "{0:0.00}";
//return Binding.DoNothing;
}