Dot in column header

Feb 10, 2009 at 10:47 AM
Hi all,

I'm triing to define column header of my datagrid using decimal value, but I remarked that, if a dot is set on ColumnName value dispear from all the corresponding column.

Here a example:

<Window x:Class="WpfApplication2.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300"
    xmlns:dgToolKit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit">
    <Grid>
        <dg:DataGrid Name="dataGrid1" Margin="10,15,60,115" ItemsSource="{Binding}" >
        </dg:DataGrid>
    </Grid>
</Window>


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;
using System.Data;

namespace WpfApplication2
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            DataTable dt = new DataTable();
            DataColumn dc = new DataColumn("Column.1");
            dc.DataType = System.Type.GetType("System.String");
            dc.AllowDBNull = false;
            dt.Columns.Add(dc);
            dc = new DataColumn("Column2");
            dt.Columns.Add(dc);

            DataRow dr = dt.NewRow();
            dr[0] = "C11";
            dr[1] = "C12";
            dt.Rows.Add(dr);


            dr = dt.NewRow();
            dr[0] = "C21";
            dr[1] = "C22";
            dt.Rows.Add(dr);

            dataGrid1.DataContext = dt.DefaultView;
            dataGrid1.FontSize = 20;
            dataGrid1.Visibility = Visibility.Visible;

        }
    }
}

On first column where there is a dot on column name C11 and C12 aren't displayed. On second column where there isn't a dot on column name C21 and C22 are correctly displayed. 

Thanks for you help!!

Irfanlh



Coordinator
Feb 10, 2009 at 7:12 PM
Hello Irfanlh,

    WPF DataBinding engine doesn't support dots in DataColumn name. This wouldn't work not just in  DataGrid AutoGeneration, but even if you were to create your own DataGridColumn definition (in fact this wouldnt work anywhere one uses such a binding).

Thanks,
Vamsee
Feb 11, 2009 at 7:53 AM
Edited Feb 11, 2009 at 7:56 AM
Thanks for your answer, Vamsee. I'll try to find another way to solve my problem!!

Irfanlh