我是WPF的新手,我遇到的问题应该看似简单。我有一个数据表,我试图绑定到DataGridComboBoxColumn。这是我的代码=请指教。加载时没有显示组合框。
<CollectionViewSource x:Key="ColorListData"/>
<DataGridComboBoxColumn Header="Color" ItemsSource="{Binding Source= {StaticResource ColorListData}}" x:Name="myColorComboBox" DisplayMemberPath="ColorName" SelectedValuePath="DataID" />
code behind:
Dim ColorListData As System.Windows.Data.CollectionViewSource = CType(Me.FindResource("ColorListData"), System.Windows.Data.CollectionViewSource)
Dim Sql As String = "Select DataID, ColorName from Colors where StyleID = @StyleID"
ReDim SqlP(0)
SqlP(0) = MyData.CreateParameter("StyleID", SqlDbType.Int, 4, StyleID)
Dim MyColorTable As DataTable = MyData.GetDataTable(Sql, "text", SqlP)
ColorListData.Source = MyColorTable.DefaultView