我有一個文本框和一個組合框作爲模板列。下面是XAML將WPf Datagrid Combobox值設置爲各自的文本框
<wpfkit:DataGrid Margin="3" Style="{DynamicResource SimpleDataGrid}"
FontWeight="Normal" MaxHeight="100" CanUserAddRows="True"
ItemsSource="{Binding Source={StaticResource odpExistingGHSCodesColl}}"
AutoGenerateColumns="False" Name="dgGHS" VerticalScrollBarVisibility="Visible"
<wpfkit:DataGrid.Columns>
<wpfkit:DataGridTemplateColumn IsReadOnly="True">
<wpfkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Style="{DynamicResource SimpleImageDelete}"/>
</DataTemplate>
</wpfkit:DataGridTemplateColumn.CellTemplate>
</wpfkit:DataGridTemplateColumn>
<wpfkit:DataGridTemplateColumn IsReadOnly="True">
<wpfkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox x:Name="cbTGHSCodes"
ItemsSource="{Binding Source={StaticResource odpGHSCodesColl}}"
DisplayMemberPath="fldCode" SelectedItem="{Binding Path=fldGHSCodeList}"
SelectedValue="fldCode" SelectedValuePath="fldDescription">
</ComboBox>
</DataTemplate>
</wpfkit:DataGridTemplateColumn.CellTemplate> </wpfkit:DataGridTemplateColumn> <wpfkit:DataGridTemplateColumn IsReadOnly="True"> <wpfkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox x:Name="tbTGHSCodeDescription" Text="{Binding Path=fldDescription, ElementName=cbTGHSCodes}"> </TextBox></DataTemplate>
</wpfkit:DataGridTemplateColumn.CellTemplate>
</wpfkit:DataGridTemplateColumn>
</wpfkit:DataGrid.Columns>
</wpfkit:DataGrid>
我有一個觀察的集合(odpGHSCodesColl)中對此我插入代碼及其相應的說明。存儲的代碼是fldCodes屬性,而fldDescription有說明。所以我想達到的目的就是說如果代碼P1有Desc ABC,P2有DFG,P4有UHY,那麼如果從組合框中選擇P1,那麼下一列中相應的文本框將被填充ABC,如果P2然後DFG等等。 我希望你能理解。我無法找到任何附加的事件。如果可能的話,給我一些XAML本身的例子,以便我需要編寫較少的代碼。
請! people @ stackoverflow,幫助我! – 2010-01-06 08:00:23