回答編集履歴
2
見直しキャンペーン中
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ComboBoxなので、選択肢を`ItemsSource`にBindingする必要があります。
|
1
|
+
ComboBoxなので、**選択肢**を`ItemsSource`にBindingする必要があります。
|
2
2
|
Categoryは`SelectedItem`にあたります。
|
3
3
|
|
4
4
|
変更した点のみ記載します。
|
1
見直しキャンペーン中
answer
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
ComboBoxなので選択肢を
|
1
|
+
ComboBoxなので、選択肢を`ItemsSource`にBindingする必要があります。
|
2
|
-
Categoryは`SelectedItem`にあたります。
|
2
|
+
Categoryは`SelectedItem`にあたります。
|
3
|
-
|
3
|
+
|
4
|
-
変更した点のみ記載します。
|
4
|
+
変更した点のみ記載します。
|
5
|
-
```
|
5
|
+
```xml
|
6
|
-
<DataTemplate>
|
6
|
+
<DataTemplate>
|
7
|
-
<ComboBox
|
7
|
+
<ComboBox
|
8
|
-
DisplayMemberPath="DisplayValue"
|
8
|
+
DisplayMemberPath="DisplayValue"
|
9
|
-
ItemsSource="{Binding CategoryTypes}"
|
9
|
+
ItemsSource="{Binding CategoryTypes}"
|
10
|
-
SelectedItem="{Binding Category, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
|
10
|
+
SelectedItem="{Binding Category, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
|
11
|
-
<!--<ComboBox.ItemsSource>
|
11
|
+
<!--<ComboBox.ItemsSource>
|
12
|
-
<x:Array Type="{x:Type viewModels:CategoryType}">
|
12
|
+
<x:Array Type="{x:Type viewModels:CategoryType}">
|
13
|
-
<x:Static Member="viewModels:CategoryType.None" />
|
13
|
+
<x:Static Member="viewModels:CategoryType.None" />
|
14
|
-
<x:Static Member="viewModels:CategoryType.Category1" />
|
14
|
+
<x:Static Member="viewModels:CategoryType.Category1" />
|
15
|
-
<x:Static Member="viewModels:CategoryType.Category2" />
|
15
|
+
<x:Static Member="viewModels:CategoryType.Category2" />
|
16
|
-
</x:Array>
|
16
|
+
</x:Array>
|
17
|
-
</ComboBox.ItemsSource>-->
|
17
|
+
</ComboBox.ItemsSource>-->
|
18
|
-
</ComboBox>
|
18
|
+
</ComboBox>
|
19
|
-
</DataTemplate>
|
19
|
+
</DataTemplate>
|
20
|
-
```
|
20
|
+
```
|
21
|
-
|
21
|
+
|
22
|
-
```
|
22
|
+
```cs
|
23
|
-
public class Item : BindableBase
|
23
|
+
public class Item : BindableBase
|
24
|
-
{
|
24
|
+
{
|
25
|
-
public string Name { get; set; }
|
25
|
+
public string Name { get; set; }
|
26
|
-
private CategoryType _category;
|
26
|
+
private CategoryType _category;
|
27
|
-
public CategoryType Category { get => _category; set => SetProperty(ref _category, value); }
|
27
|
+
public CategoryType Category { get => _category; set => SetProperty(ref _category, value); }
|
28
|
-
|
28
|
+
|
29
|
-
// なんだかなって気もするのでxamlで与えたほうがいいか?
|
29
|
+
// なんだかなって気もするのでxamlで与えたほうがいいか?
|
30
|
-
// xamlで指定する場合は入れ子だとエラーになるのでclass CategoryTypeを外に出す必要あり
|
30
|
+
// xamlで指定する場合は入れ子だとエラーになるのでclass CategoryTypeを外に出す必要あり
|
31
|
-
public static List<CategoryType> CategoryTypes { get; } = new List<CategoryType> { CategoryType.None, CategoryType.Category1, CategoryType.Category2 };
|
31
|
+
public static List<CategoryType> CategoryTypes { get; } = new List<CategoryType> { CategoryType.None, CategoryType.Category1, CategoryType.Category2 };
|
32
|
-
}
|
32
|
+
}
|
33
33
|
```
|