I'm trying to get a subproperty formatted, but it doesn't seem to be working. It's just showing the value without any formatting.
My xaml:
| <Window x:Class="GridFormatTest.MainWindow" |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| Title="MainWindow" Height="350" Width="525" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:System="clr-namespace:System;assembly=mscorlib"> |
| <Grid Loaded="Grid_Loaded"> |
| <telerik:RadGridView HorizontalAlignment="Left" Name="radGridView1" VerticalAlignment="Top" Height="311" Width="503"> |
| <telerik:RadGridView.Columns> |
| <telerik:GridViewDataColumn Header="Works" DataMemberBinding="{Binding Size}" DataFormatString="{}{0:N}"/> |
| <telerik:GridViewDataColumn Header="Doesn't work" DataMemberBinding="{Binding SubItem.SubSize}" DataFormatString="{}{0:N}" DataType="{x:Type System:Double}"/> |
| </telerik:RadGridView.Columns> |
| </telerik:RadGridView> |
| </Grid> |
| </Window> |
The code:
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Text; |
| using System.Windows; |
| using System.Windows.Controls; |
| using System.Windows.Data; |
| using System.Windows.Documents; |
| using System.Windows.Input; |
| using System.Windows.Media; |
| using System.Windows.Media.Imaging; |
| using System.Windows.Navigation; |
| using System.Windows.Shapes; |
| namespace GridFormatTest |
| { |
| public class Order |
| { |
| public Order() |
| { |
| this.Size = 12000.0; |
| this.SubItem = new SubOrder(); |
| } |
| public double Size { get; private set; } |
| public SubOrder SubItem { get; set; } |
| } |
| public class SubOrder |
| { |
| public SubOrder() |
| { |
| this.SubSize = 150000; |
| } |
| public double SubSize { get; set; } |
| } |
| /// <summary> |
| /// Interaction logic for MainWindow.xaml |
| /// </summary> |
| public partial class MainWindow : Window |
| { |
| public MainWindow() |
| { |
| InitializeComponent(); |
| } |
| private void Grid_Loaded(object sender, RoutedEventArgs e) |
| { |
| radGridView1.ItemsSource = new List<Order> |
| { |
| new Order(), |
| new Order() |
| }; |
| } |
| } |
| } |
As you can see I've also tried to set the DataType manually, which I noticed was the solution to another similar problem I found on the forums. But that doesn't help.
Any suggestions?