我在一侧使用SiverLight Datagrid,一个下拉列表和标签在下拉SelectedIndexChanged 事件中我想找到标签并分配DropdownList 的选定值。
Xaml 页面:
<sdk:DataGridTemplateColumn Header="New Receipe" CanUserSort="True" >
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Border Style="{StaticResource GridBackgroundBorder}" Background="{Binding Path=IsActive, Converter={StaticResource BoolToBackgroundValueConverter1}}"></Border>
<sdk:Label Margin="5,0,5,0" x:Name="lblCompVer" Content="{Binding Path=Version}" Height="Auto" VerticalAlignment="Center" Foreground="{Binding Path=IsActive, Converter={StaticResource BoolToForegroundValueConverter1}}"/>
</Grid>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
<sdk:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<Grid>
<ComboBox Height="Auto" SelectionChanged="cboCompVerSel_SelectionChanged" x:Name="cboCompVerSel" ItemsSource="{Binding Path=CompVerList,Mode=TwoWay}" SelectedItem="{Binding Mode=OneWay, Path=Version}" Visibility="{Binding Path=IsActive, Converter={StaticResource BoolToVisibilityValueConverter1}}"/>
<!--<TextBox Height="Auto" Text="{Binding Mode=TwoWay, Path=Version}" x:Name="TextBoxCodeVer" Visibility="{Binding Path=IsActive, Converter={StaticResource BoolToVisibilityValueConverter1}}" AcceptsReturn="True"></TextBox>-->
</Grid>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellEditingTemplate>
</sdk:DataGridTemplateColumn>
DropDownlist SelectionChanged 事件:
Private Sub cboCompVerSel_SelectionChanged(ByVal sender As System.Object, ByVal e As
System.Windows.Controls.SelectionChangedEventArgs)
Dim src = TryCast(sender, ComboBox)
If src IsNot Nothing Then
Dim fe As FrameworkElement = CType(src.Parent, FrameworkElement)
Dim gridCmbo As Grid = DirectCast(fe, Grid)
Dim lblCompVer As Label = CType(gridCmbo.FindName("lblCompVer"), Label)
lblCompVer.DataContext = src.SelectedItem
End If
End Sub
我无法识别 lblCompVer 控件来分配下拉选择的值