我是WPF的新手。我有一个wpftoolkit数据网格,我使用组合框作为datagridcombox列。我正在使用一个可观察的代码集合来绑定组合框。以下是该集合及其类......
#Region "Class & Coll"
Public Class CodesColl
Inherits ObservableCollection(Of Codes)
End Class
Public Class Codes
Private pCode As String
Private pDescription As String
Public Sub New()
pCode = String.Empty
pDescription = String.Empty
End Sub
#End Region
#Region "Property"
Public Property fldCode() As String
Get
Return pCode
End Get
Set(ByVal value As String)
pCode = value
End Set
End Property
Public Property fldDescription() As String
Get
Return pDescription
End Get
Set(ByVal value As String)
pDescription = value
End Set
End Property
#End Region
End Class
现在我想要实现的是我需要用网格中的下拉列表绑定集合。在我的网格中我在第一列中有两列我必须显示代码(fldCode),并且在选择代码时同一行的下一列将填充其描述(fldDescription)。
我的Xaml是这样的:
<wpfkit:DataGrid Margin="3" Style="{DynamicResource SimpleDataGrid}" FontWeight="Normal"
MaxHeight="100" ItemsSource="{Binding Source={StaticResource odpExistingCodesColl}}"
AutoGenerateColumns="False" Name="dgCodes" VerticalScrollBarVisibility="Visible" >
<wpfkit:DataGrid.Columns>
<wpfkit:DataGridTemplateColumn IsReadOnly="True">
<wpfkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Style="{DynamicResource SimpleImageDelete}"/>
</DataTemplate>
</wpfkit:DataGridTemplateColumn.CellTemplate>
</wpfkit:DataGridTemplateColumn>
<wpfkit:DataGridComboBoxColumn Header="Code"
DisplayMemberPath="fldCode"
SelectedValueBinding="{Binding fldCodes.fldCode}"
SelectedValuePath="fldCode"
SelectedItemBinding="{Binding fldCodeList}"
Width="100" x:Name="cbTCodes" >
<wpfkit:DataGridComboBoxColumn.ElementStyle>
<Style TargetType="ComboBox">
<Setter Property="IsSynchronizedWithCurrentItem" Value="False" />
<Setter Property ="ItemsSource" Value="{Binding Path=odpCodesColl}"/>
</Style>
</wpfkit:DataGridComboBoxColumn.ElementStyle>
<wpfkit:DataGridComboBoxColumn.EditingElementStyle >
<Style TargetType="ComboBox">
<Setter Property ="ItemsSource" Value="{Binding Path=odpCodesColl}"/>
<Setter Property ="IsDropDownOpen" Value="True"/>
</Style>
</wpfkit:DataGridComboBoxColumn.EditingElementStyle>
</wpfkit:DataGridComboBoxColumn>
<wpfkit:DataGridTextColumn Width="375" Header="Description" x:Name="tbTCodeDescription" />
</wpfkit:DataGrid.Columns>
</wpfkit:DataGrid>
odpExistingCodesColl这里是另一个集合,通过它我绑定整个网格,用于发送代码及其描述,但我面临以下问题
所以你们要求尽快帮助我..任何帮助都将受到高度赞赏.. 提前致谢 Amit Ranjan