質問編集履歴

1

解決後の補足を追加。

2017/09/06 02:48

投稿

twyujiro15
twyujiro15

スコア217

test CHANGED
File without changes
test CHANGED
@@ -121,3 +121,71 @@
121
121
 
122
122
 
123
123
  なぜこのような現象になるのか説明していただけないでしょうか。
124
+
125
+
126
+
127
+ ---
128
+
129
+
130
+
131
+ (2017/09/06 追記)
132
+
133
+ 解決できました。ありがとうございます。
134
+
135
+
136
+
137
+ 回答を参考に CollectionViewSource を使わず、Array を使用することで問題を回避できました。
138
+
139
+
140
+
141
+ ```XAML
142
+
143
+ <Window x:Class="WpfApplication1.MainWindow"
144
+
145
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
146
+
147
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
148
+
149
+ xmlns:sys="clr-namespace:System;assembly=mscorlib"
150
+
151
+ Title="MainWindow" Height="350" Width="525">
152
+
153
+ <StackPanel>
154
+
155
+ <StackPanel.Resources>
156
+
157
+ <!--<CollectionViewSource x:Key="collection" Source="{Binding Names}" />-->
158
+
159
+ <x:Array x:Key="array" Type="{x:Type sys:String}">
160
+
161
+ <sys:String>item1</sys:String>
162
+
163
+ <sys:String>item2</sys:String>
164
+
165
+ <sys:String>item3</sys:String>
166
+
167
+ <sys:String>item4</sys:String>
168
+
169
+ </x:Array>
170
+
171
+ </StackPanel.Resources>
172
+
173
+
174
+
175
+ <ComboBox x:Name="combobox1" ItemsSource="{Binding Source={StaticResource array}}" />
176
+
177
+ <ComboBox x:Name="combobox2" ItemsSource="{Binding Source={StaticResource array}}" />
178
+
179
+ <TextBlock Text="{Binding SelectedItem, ElementName=combobox1}" />
180
+
181
+ </StackPanel>
182
+
183
+ </Window>
184
+
185
+
186
+
187
+ ```
188
+
189
+
190
+
191
+ また、ComboBox.IsSynchronizedWithCurrentItem プロパティを利用することでも問題を回避できました。