Created
April 11, 2015 13:50
-
-
Save mollyporph/cb31eec2e149394429a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.ObjectModel; | |
using System.Windows; | |
namespace datagridTest | |
{ | |
/// <summary> | |
/// Interaction logic for MainWindow.xaml | |
/// </summary> | |
public partial class MainWindow : Window | |
{ | |
private ObservableCollection<Data> myList; | |
public MainWindow() | |
{ | |
myList = new ObservableCollection<Data>(); | |
InitializeComponent(); | |
dataGrid1.ItemsSource = myList; | |
} | |
private void MinFinaKnapp_OnClick(object sender, RoutedEventArgs e) | |
{ | |
myList.Add(new Data | |
{ | |
Date = DateTime.Now, | |
Name = Guid.NewGuid().ToString() | |
}); | |
} | |
} | |
public class Data | |
{ | |
public string Name { get; set; } | |
public DateTime Date { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="datagridTest.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"> | |
<Grid> | |
<Grid.RowDefinitions> | |
<RowDefinition Height="90*"></RowDefinition> | |
<RowDefinition Height="10*"></RowDefinition> | |
</Grid.RowDefinitions> | |
<DataGrid Name="dataGrid1" Grid.Row="0" ItemsSource="{Binding Data}" AutoGenerateColumns="False" > | |
<DataGrid.Columns> | |
<DataGridTextColumn Header="ID" Binding="{Binding Name}"/> | |
<DataGridTextColumn Header="Date" Binding="{Binding Date}"/> | |
</DataGrid.Columns> | |
</DataGrid> | |
<Button Name="MinFinaKnapp" Grid.Row="1" Click="MinFinaKnapp_OnClick">CLICK ME OMFGSDASd</Button> | |
</Grid> | |
</Window> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment