Monday, September 10, 2012

Adding an Item to WPF Datagrid (C#)

Here's the c# .net version.
Code:
DataGridTextColumn c1 = new DataGridTextColumn();  
c1.Header = "Test";  
c1.Binding = new Binding("test");  
 c1.Width = 473;  
dataGrid.Columns.Add(c1);  
dataGrid.Items.Add(new Names() {test="just testing"});
Class property:
Code:
public string test { get; set; }  
XAML code:
 <DataGrid AutoGenerateColumns="False" Height="289" HorizontalAlignment="Left" Margin="10,10,0,0" Name="dataGrid"   
          VerticalAlignment="Top" Width="481" Grid.ColumnSpan="2" ItemsSource="{Binding }">  
     </DataGrid>  
:)

0 comments:

Post a Comment