Hey everyone,
I have the following problem and I hope I just oversee a simple step. (First of all: Sorry, there are lots of german words in it, but it should be understandable what the problem is.)
In picture1 (see attached files) is shown how my RadGridView looks like. Behind the RadGridView my View (using MVVM) is build like that:
<
telerik:RadGridView
Grid.Row
=
"3"
Grid.Column
=
"0"
Grid.ColumnSpan
=
"4"
HorizontalAlignment
=
"Center"
ShowGroupPanel
=
"False"
ItemsSource
=
"{Binding Path=RowPLIGFKU.Rabattstaffel, ValidatesOnDataErrors=True}"
AutoGenerateColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"{Loc Key=PREISLISTE_LIST_RABATTSTAFFEL_ABMENGE}"
DataMemberBinding
=
"{Binding Path=[PGSTA]}"
MinWidth
=
"80"
/>
<
telerik:GridViewMaskedInputColumn
Header
=
"{Loc Key=PREISLISTE_LIST_RABATTSTAFFEL_RABATT}"
DataMemberBinding
=
"{Binding Path=[PGRAB]}"
MinWidth
=
"80"
DataFormatString
=
"{}{0:n2} %"
/>
<
telerik:GridViewMaskedInputColumn
Header
=
"{Loc Key=PREISLISTE_LIST_RABATTSTAFFEL_WERT}"
DataMemberBinding
=
"{Binding Path=[PGPRS]}"
MinWidth
=
"80"
DataFormatString
=
"{Binding RabattstaffelCurrency}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
In the second column I use the numeric DataFormatString, cause of some reason, when I use the actual percent DataFormatString ("{}{0:P}") I get 500% as result by input 5. - But why?!?! In my opinion that makes no sense. Really: Who needs this that way?
However, my problem is in the third column, where I bind my DataFormatString to the proberty 'RabattstaffelCurrency'.
This is how I set the proberty in the ViewModel:
RabattstaffelCurrency =
string
.Format(
"{0} {1}"
,
"{}{0:n2}"
, Session.Company.Value<Waehrung>(CompanyInfos.DefaultCurrency));
The result is shown in picture2. It is "{}{0:n2} EUR". And by seeing this picture it gets clear why I can't just write: {0:c2}. I need the abbreviation of the actual currency, not the symbol and that changes at the runtime by user interacitons.
If I write it hardcoded like this "{}{0:n2} EUR" it works. I don't get a binding error or some other details, its just shows the data. And last but not least I need to say that this is a project at my work, so I have not the opportunity to implement some workarounds.