tags:

views:

110

answers:

0

Hi,

I have a WPF DataGrid control I am binding the objects of class Customer to DataGrid Rows using ObservableCollection at run time. I have set MinRowHeight="100" & I want the rows of DataGrid should be HorizontallyAligned at Center & Vertically at Center. Setting DataGrid properties VerticalContentAlignment="Center" HorizontalContentAlignment="Center" doesn't help.

XAML CODE ::

< my:DataGrid Name="dataGrid1" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding}" MinRowHeight="100" SelectionMode="Single" SelectionUnit="Cell" IsReadOnly="True" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>

C# ::

System.Collections.ObjectModel.ObservableCollection<Customer> cust1 = new System.Collections.ObjectModel.ObservableCollection<Customer>

{ new Customer{FirstName="JACK",LastName="JOE",IsMember = true ,Email="[email protected]",Status=OrderStatus.Processing }, new Customer{FirstName="Neville",LastName="SAM",IsMember = true ,Email="[email protected]",Status=OrderStatus.Received }, };

dataGrid1.ItemsSource  = cust1;


public class Customer
{
    public string FirstName{get;set;}
    public string LastName { get; set; }
    public string Email { get; set; }
    public bool IsMember { get; set; }
    public OrderStatus Status { get; set; }
}

Any help will be greatly appreciated,

Thanx