teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

ソース追加

2015/09/02 02:37

投稿

yisland
yisland

スコア28

title CHANGED
File without changes
body CHANGED
@@ -3,4 +3,98 @@
3
3
  WPF
4
4
 
5
5
  WPFのDataGrid内に動的に生成したコンボボックスを表示させる方法が分かりません。
6
- どなたか分かる方がいらしたら教えて頂きたいです。
6
+ どなたか分かる方がいらしたら教えて頂きたいです。
7
+
8
+ **追加**
9
+ ```
10
+ <Window x:Class="Window2"
11
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
12
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
13
+ Title="Window2" Height="383" Width="666">
14
+ <StackPanel Orientation="Vertical">
15
+
16
+ <DataGrid Grid.Row="1" Name="DataGrid1" AutoGenerateColumns="False" Height="300" >
17
+ <DataGrid.Columns>
18
+ <DataGridTemplateColumn>
19
+ <DataGridTemplateColumn.Header>
20
+ <Grid>
21
+ <Grid.RowDefinitions>
22
+ <RowDefinition />
23
+ <RowDefinition />
24
+ </Grid.RowDefinitions>
25
+ <Label Grid.Row="0" Grid.RowSpan="2" Content="てすと1" />
26
+ </Grid>
27
+ </DataGridTemplateColumn.Header>
28
+
29
+ <DataGridTemplateColumn.CellTemplate>
30
+ <DataTemplate>
31
+ <Grid>
32
+ <Grid.RowDefinitions>
33
+ <RowDefinition />
34
+ <RowDefinition />
35
+ </Grid.RowDefinitions>
36
+ <Label Grid.Row="0" Grid.RowSpan="2" Content="{Binding Test1}" />
37
+ </Grid>
38
+ </DataTemplate>
39
+ </DataGridTemplateColumn.CellTemplate>
40
+ </DataGridTemplateColumn>
41
+
42
+ <DataGridTemplateColumn>
43
+ <DataGridTemplateColumn.Header>
44
+ <DataGridColumnHeader>
45
+ <Grid>
46
+ <Grid.RowDefinitions>
47
+ <RowDefinition />
48
+ <RowDefinition />
49
+ </Grid.RowDefinitions>
50
+ <Label Grid.Row="0" Content="てすと2" />
51
+ <Label Grid.Row="1" Content="てすと3" />
52
+ </Grid>
53
+ </DataGridColumnHeader>
54
+ </DataGridTemplateColumn.Header>
55
+
56
+ <DataGridTemplateColumn.CellTemplate>
57
+ <DataTemplate>
58
+ <Grid>
59
+ <Grid.RowDefinitions>
60
+ <RowDefinition />
61
+ <RowDefinition />
62
+ </Grid.RowDefinitions>
63
+ <Label Grid.Row="0" Content="{Binding Test2}" />
64
+ <Label Grid.Row="1" Content="{Binding Test3}" />
65
+ </Grid>
66
+ </DataTemplate>
67
+ </DataGridTemplateColumn.CellTemplate>
68
+ </DataGridTemplateColumn>
69
+
70
+ <DataGridTemplateColumn>
71
+ <DataGridTemplateColumn.Header>
72
+ <Grid>
73
+ <Grid.RowDefinitions>
74
+ <RowDefinition />
75
+ <RowDefinition />
76
+ </Grid.RowDefinitions>
77
+ <Label Grid.Row="0" Grid.RowSpan="2" Content="コンボボックス" />
78
+ </Grid>
79
+ </DataGridTemplateColumn.Header>
80
+
81
+ <DataGridTemplateColumn.CellTemplate>
82
+ <DataTemplate>
83
+ <Grid>
84
+ <Grid.RowDefinitions>
85
+ <RowDefinition />
86
+ <RowDefinition />
87
+ </Grid.RowDefinitions>
88
+ <ComboBox Name="comboTest" />
89
+ </Grid>
90
+ </DataTemplate>
91
+ </DataGridTemplateColumn.CellTemplate>
92
+ </DataGridTemplateColumn>
93
+
94
+ </DataGrid.Columns>
95
+ </DataGrid>
96
+ </StackPanel>
97
+ </Window>
98
+
99
+ ```
100
+ ViewModelでDataGridのItemsSourceにどうやって設定すればいいのかが分かりません。