0

ComboBoxaとa の間で基本的なバインディングを機能させるにはどうすればよいObservableCollectionですか? エラーメッセージしか表示されません。

VB:

Class MainWindow
    Dim Units As New ObservableCollection(Of String)

    Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        Units.Clear()
        Units.Add("in")
        Units.Add("mm")
        Units.Add("cm")
    End Sub
End Class

XAML:

<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
    <ComboBox Height="59" HorizontalAlignment="Left" Margin="136,96,0,0" Name="ComboBox1" VerticalAlignment="Top" Width="319"
              ItemsSource="{Binding Units}"/>
</Grid>

私が何をしても、ComboBox常に空のように見え、コンソールにエラーメッセージが表示されます:

System.Windows.Data エラー: 40: BindingExpression パス エラー: 'Units' プロパティが 'object' ''MainWindow' (Name='')' に見つかりません。BindingExpression: パス = 単位; DataItem='MainWindow' (Name=''); ターゲット要素は 'ComboBox' (Name='ComboBox1') です。ターゲット プロパティは 'ItemsSource' (タイプ 'IEnumerable') です。

4

1 に答える 1