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

回答編集履歴

2

修正

2019/09/24 10:15

投稿

Zuishin
Zuishin

スコア28675

answer CHANGED
@@ -22,11 +22,6 @@
22
22
  <Setter Property="IsSelected" Value="{Binding IsChecked}"/>
23
23
  </Style>
24
24
  </DataGrid.ItemContainerStyle>
25
- <DataGrid.ItemTemplate>
26
- <DataTemplate>
27
- <CheckBox IsChecked="{Binding IsChecked}" Content="{Binding Text}"/>
28
- </DataTemplate>
29
- </DataGrid.ItemTemplate>
30
25
  </DataGrid>
31
26
  </Grid>
32
27
  </Window>

1

ListBox を DataGrid に変更

2019/09/24 10:15

投稿

Zuishin
Zuishin

スコア28675

answer CHANGED
@@ -16,18 +16,18 @@
16
16
  <local:MainViewModel/>
17
17
  </Window.DataContext>
18
18
  <Grid>
19
- <ListBox ItemsSource="{Binding Items}" SelectionMode="Multiple">
19
+ <DataGrid ItemsSource="{Binding Items}" SelectionMode="Extended">
20
- <ListBox.ItemContainerStyle>
20
+ <DataGrid.ItemContainerStyle>
21
- <Style TargetType="{x:Type ListBoxItem}">
21
+ <Style TargetType="{x:Type DataGridRow}">
22
22
  <Setter Property="IsSelected" Value="{Binding IsChecked}"/>
23
23
  </Style>
24
- </ListBox.ItemContainerStyle>
24
+ </DataGrid.ItemContainerStyle>
25
- <ListBox.ItemTemplate>
25
+ <DataGrid.ItemTemplate>
26
26
  <DataTemplate>
27
27
  <CheckBox IsChecked="{Binding IsChecked}" Content="{Binding Text}"/>
28
28
  </DataTemplate>
29
- </ListBox.ItemTemplate>
29
+ </DataGrid.ItemTemplate>
30
- </ListBox>
30
+ </DataGrid>
31
31
  </Grid>
32
32
  </Window>
33
33
  ```