I have a List that i bind to a Telerik RadGrid View. Everything works fine. My Object contains two attributes a Currency Symbol and a Price. I use
<telerik:GridViewDataColumn DataMemberBinding="{Binding BallPrice}" Header="Price"/>.
Now the Object i bind to also has a currecy symbol .So i want this column to also include that currency symbol, something like
<telerik:GridViewDataColumn DataMemberBinding="{Binding BallPrice} +{Binding Symbol}" Header="Price"/>.
How can i do this ?
Kind Regards.
Answer: 1
Did you try adding in DataFormatString="{0:c}"? That should format it as currency.
by : Philhttp://stackoverflow.com/users/973890Answer: 2
What I will do in this case is use template in column. So it will be something like this.
<telerikGridView:GridViewDataColumn Header="Price"> <telerikGridView:GridViewDataColumn.CellTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding BallPrice}"/> <TextBlock Text="{Binding Symbol}"/> </StackPanel> </DataTemplate> </telerikGridView:GridViewDataColumn.CellTemplate>
by : Manojhttp://stackoverflow.com/users/164811Answer: 3
I do not know if Multibinding works on columns in RadGridView but it's one solution:
<telerik:GridViewDataColumn> <telerik:GridViewDataColumn.DataMemberBinding> <MultiBinding StringFormat="[{0} {1}]"> <Binding Path="BallPrice" /> <Binding Path="Symbol" /> </MultiBinding> </telerik:GridViewDataColumn.DataMemberBinding> </telerik:GridViewDataColumn>
I would however consider, if you are able, to add a new property to the object that combines the two properties like this:
public string Price { get { return string.format("{0} {1}", this.BallPrice, this.Symbol); } }
And simply bind to that.
If you are using MVVM this should work very well in the ViewModel and you can set NotifyPropertyChanged on both the BallPrice and Symbol properties if they can change on runtime.
by : Ingó Valshttp://stackoverflow.com/users/302251
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog