Advertisement
k_vychodilova

c#

Sep 26th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. <Grid>
  2. <Grid.ColumnDefinitions>
  3. <ColumnDefinition Width="Auto"/>
  4. <ColumnDefinition Width="2*"/>
  5. <ColumnDefinition Width="3*"/>
  6. </Grid.ColumnDefinitions>
  7.  
  8. <Grid.RowDefinitions>
  9. <RowDefinition Height="Auto"/>
  10. <RowDefinition Height="*"/>
  11. </Grid.RowDefinitions>
  12.  
  13. <ComboBox Grid.Row="0" Grid.Column="0" SelectedItem="{Binding SelectedStudent}" ItemsSource="{Binding Studenti}">
  14. <ComboBox.ItemTemplate>
  15. <DataTemplate>
  16. <TextBlock Text="{Binding Jmeno}" />
  17. </DataTemplate>
  18. </ComboBox.ItemTemplate>
  19. </ComboBox>
  20. <TextBlock Grid.Row="0" Grid.Column="1" Text="Ahoj" />
  21. <ListBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Polozky}">
  22. <ListBox.ItemTemplate>
  23. <DataTemplate>
  24. <StackPanel>
  25. <TextBlock Text="{Binding Datum}" />
  26. <TextBlock Text="{Binding Id}" />
  27. </StackPanel>
  28. </DataTemplate>
  29. </ListBox.ItemTemplate>
  30. </ListBox>
  31.  
  32. <DataGrid Grid.Row="0" Grid.Column="2" Grid.RowSpan="3" ItemsSource="{Binding Polozky}" />
  33. </Grid>
  34.  
  35. public class Polozka
  36. {
  37. public DateTime Datum { get; set; }
  38. public int Id { get; set; }
  39.  
  40. public Polozka(int id)
  41. {
  42. Datum = DateTime.Now.AddHours(id);
  43. Id = id;
  44. }
  45. }
  46.  
  47. public class Data
  48. {
  49. public List<Polozka> Polozky { get; set; }
  50. public List<Student> Studenti { get; set; }
  51. public Student SelectedStudent { get; set; }
  52.  
  53. public Data()
  54. {
  55. Polozky = new List<Polozka>()
  56. {
  57. new Polozka(1),
  58. new Polozka(2),
  59. new Polozka(3)
  60. };
  61.  
  62. Studenti = new List<Student>()
  63. {
  64. new Student("Adam"),
  65. new Student("Alena"),
  66. new Student("Jirka"),
  67. new Student("Matúš"),
  68. new Student("Samuel")
  69. };
  70.  
  71. SelectedStudent = Studenti.FirstOrDefault();
  72. }
  73. }
  74.  
  75. protected override void OnStartup(StartupEventArgs e)
  76. {
  77. base.OnStartup(e);
  78.  
  79. Data data = new Data();
  80.  
  81. MainWindow window = new MainWindow();
  82. window.DataContext = data;
  83. window.ShowDialog();
  84.  
  85. }
  86.  
  87. public class Student
  88. {
  89. public string Jmeno { get; set; }
  90.  
  91. public Student(string jmeno)
  92. {
  93. Jmeno = jmeno;
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement