2
我有一個包含Int32對象集合的組合框。 ComboBox SelectedItem綁定到Int32。UWP組合框未顯示綁定項目
<ComboBox>
<ComboBox.SelectedItem>
<Binding Path="MidiChannel" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" />
</ComboBox.SelectedItem>
<ComboBox.Items>
<ComboBoxItem>
<x:Int32>0</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>1</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>2</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>3</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>4</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>5</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>6</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>7</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>8</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>9</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>10</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>11</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>12</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>13</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>14</x:Int32>
</ComboBoxItem>
<ComboBoxItem>
<x:Int32>15</x:Int32>
</ComboBoxItem>
</ComboBox.Items>
</ComboBox>
MidiChannel屬性實現INotifyPropertyChanged。
無論我嘗試什麼樣的組合,切換集合和SelectedItem,使用SelectedValue而不是SelectedItem。 ComboBox不會在UI中顯示SelectedItem。輸出不顯示任何綁定錯誤,並且我已檢查Int32存在於該類中。我怎樣才能讓ComboBox顯示我的Int32?
不要發佈MidiChannel財產的完整性。 Foir實例,它是一個Int32? –