This is a migrated thread and some comments may be shown as answers.

DataFormatString on sub-property

2 Answers 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Geoff Smith
Top achievements
Rank 1
Geoff Smith asked on 14 Apr 2010, 02:53 PM
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 { getprivate set; } 
 
        public SubOrder SubItem { getset; } 
    } 
 
    public class SubOrder 
    { 
        public SubOrder() 
        { 
            this.SubSize = 150000; 
        } 
 
        public double SubSize { getset; } 
    } 
 
    /// <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?

2 Answers, 1 is accepted

Sort by
0
Geoff Smith
Top achievements
Rank 1
answered on 14 Apr 2010, 03:09 PM
An IValueConverter works fine, so I'll use that for now. But would be great if I could use DataFormatString instead if possible...
0
Yordanka
Telerik team
answered on 15 Apr 2010, 10:31 AM
Hello Geoff Smith,

This issue has been already fixed. If you upgrade your version to the latest one (version 412) you will be able to achive your goals without using IValueConverter.

Best wishes,
Yordanka
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Geoff Smith
Top achievements
Rank 1
Answers by
Geoff Smith
Top achievements
Rank 1
Yordanka
Telerik team
Share this question
or