回答編集履歴
4
111
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
こんな感じでしょうか
|
2
2
|
|
3
|
-
CollectionViewSource.Filterを使います
|
3
|
+
CollectionViewSource.View.Filterを使います
|
4
4
|
|
5
5
|
|
6
6
|
|
3
コメント
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
こんな感じでしょうか
|
2
|
+
|
3
|
+
CollectionViewSource.Filterを使います
|
2
4
|
|
3
5
|
|
4
6
|
|
2
アイテム
test
CHANGED
@@ -1,3 +1,121 @@
|
|
1
|
-
こ
|
1
|
+
こんな感じでしょうか
|
2
2
|
|
3
|
+
|
4
|
+
|
5
|
+
```XAML
|
6
|
+
|
7
|
+
<Window x:Class="WpfApplication1.MainWindow"
|
8
|
+
|
9
|
+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
10
|
+
|
11
|
+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
12
|
+
|
13
|
+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
14
|
+
|
15
|
+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
16
|
+
|
17
|
+
xmlns:local="clr-namespace:WpfApplication30"
|
18
|
+
|
19
|
+
mc:Ignorable="d"
|
20
|
+
|
21
|
+
Title="MainWindow" Height="350" Width="525">
|
22
|
+
|
23
|
+
<Grid>
|
24
|
+
|
25
|
+
<ComboBox x:Name="comboBox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" DisplayMemberPath="Name" SelectedValuePath="Id"/>
|
26
|
+
|
27
|
+
</Grid>
|
28
|
+
|
29
|
+
</Window>
|
30
|
+
|
31
|
+
```
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
```C#
|
36
|
+
|
37
|
+
using System.Collections.ObjectModel;
|
38
|
+
|
39
|
+
using System.Windows;
|
40
|
+
|
41
|
+
using System.Windows.Data;
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
namespace WpfApplication1
|
46
|
+
|
47
|
+
{
|
48
|
+
|
49
|
+
/// <summary>
|
50
|
+
|
51
|
+
/// MainWindow.xaml の相互作用ロジック
|
52
|
+
|
53
|
+
/// </summary>
|
54
|
+
|
55
|
+
public partial class MainWindow : Window
|
56
|
+
|
57
|
+
{
|
58
|
+
|
59
|
+
private class Hoge
|
60
|
+
|
61
|
+
{
|
62
|
+
|
63
|
+
public int ID { get; set; }
|
64
|
+
|
65
|
+
public string Name { get; set; }
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
private ObservableCollection<Hoge> HogeItems { get; set; }
|
72
|
+
|
73
|
+
private CollectionViewSource HogeViewSource { get; set; }
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
public MainWindow()
|
78
|
+
|
79
|
+
{
|
80
|
+
|
81
|
+
InitializeComponent();
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
this.HogeItems = new ObservableCollection<Hoge>();
|
86
|
+
|
87
|
+
this.HogeViewSource = new CollectionViewSource() { Source = this.HogeItems };
|
88
|
+
|
3
|
-
comboBox.
|
89
|
+
this.comboBox.ItemsSource = this.HogeViewSource.View;
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
this.HogeItems.Add(new Hoge { ID = 1, Name = "A" });
|
94
|
+
|
95
|
+
this.HogeItems.Add(new Hoge { ID = 2, Name = "B" });
|
96
|
+
|
97
|
+
this.HogeItems.Add(new Hoge { ID = 3, Name = "C" });
|
98
|
+
|
99
|
+
this.HogeItems.Add(new Hoge { ID = 4, Name = "D" });
|
100
|
+
|
101
|
+
this.HogeItems.Add(new Hoge { ID = 5, Name = "E" });
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
this.HogeViewSource.View.Filter = (n) =>
|
106
|
+
|
107
|
+
{
|
108
|
+
|
109
|
+
var item = n as Hoge;
|
110
|
+
|
111
|
+
return item.ID > 2;
|
112
|
+
|
113
|
+
};
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
```
|
1
非表示
test
CHANGED
@@ -1,129 +1,3 @@
|
|
1
|
-
こ
|
1
|
+
これでしょうか
|
2
2
|
|
3
|
-
CollectionViewSourceを使います
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
```XAML
|
12
|
-
|
13
|
-
<Window x:Class="WpfApplication1.MainWindow"
|
14
|
-
|
15
|
-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
16
|
-
|
17
|
-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
18
|
-
|
19
|
-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
20
|
-
|
21
|
-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
22
|
-
|
23
|
-
xmlns:local="clr-namespace:WpfApplication30"
|
24
|
-
|
25
|
-
mc:Ignorable="d"
|
26
|
-
|
27
|
-
Title="MainWindow" Height="350" Width="525">
|
28
|
-
|
29
|
-
<Grid>
|
30
|
-
|
31
|
-
<ComboBox x:Name="comboBox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" DisplayMemberPath="Name" SelectedValuePath="Id"/>
|
32
|
-
|
33
|
-
</Grid>
|
34
|
-
|
35
|
-
</Window>
|
36
|
-
|
37
|
-
```
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
```C#
|
42
|
-
|
43
|
-
using System.Collections.ObjectModel;
|
44
|
-
|
45
|
-
using System.Windows;
|
46
|
-
|
47
|
-
using System.Windows.Data;
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
namespace WpfApplication1
|
52
|
-
|
53
|
-
{
|
54
|
-
|
55
|
-
/// <summary>
|
56
|
-
|
57
|
-
/// MainWindow.xaml の相互作用ロジック
|
58
|
-
|
59
|
-
/// </summary>
|
60
|
-
|
61
|
-
public partial class MainWindow : Window
|
62
|
-
|
63
|
-
{
|
64
|
-
|
65
|
-
private class Hoge
|
66
|
-
|
67
|
-
{
|
68
|
-
|
69
|
-
public int ID { get; set; }
|
70
|
-
|
71
|
-
public string Name { get; set; }
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
private ObservableCollection<Hoge> HogeItems { get; set; }
|
78
|
-
|
79
|
-
private CollectionViewSource HogeViewSource { get; set; }
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
public MainWindow()
|
84
|
-
|
85
|
-
{
|
86
|
-
|
87
|
-
InitializeComponent();
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
this.HogeItems = new ObservableCollection<Hoge>();
|
92
|
-
|
93
|
-
this.HogeViewSource = new CollectionViewSource() { Source = this.HogeItems };
|
94
|
-
|
95
|
-
|
3
|
+
comboBox.Visibility = Visibility.Collapsed;
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
this.HogeItems.Add(new Hoge { ID = 1, Name = "A" });
|
100
|
-
|
101
|
-
this.HogeItems.Add(new Hoge { ID = 2, Name = "B" });
|
102
|
-
|
103
|
-
this.HogeItems.Add(new Hoge { ID = 3, Name = "C" });
|
104
|
-
|
105
|
-
this.HogeItems.Add(new Hoge { ID = 4, Name = "D" });
|
106
|
-
|
107
|
-
this.HogeItems.Add(new Hoge { ID = 5, Name = "E" });
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
this.HogeViewSource.View.Filter = (n) =>
|
112
|
-
|
113
|
-
{
|
114
|
-
|
115
|
-
var item = n as Hoge;
|
116
|
-
|
117
|
-
return item.ID > 2;
|
118
|
-
|
119
|
-
};
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
```
|