0

如何在 silverlight 代码后面将所选值设置为 Combobox。

代码如下:

<sdk:DataGridTemplateColumn Header="Risk">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Grid>
                                    <ComboBox Height="Auto" x:Name="ComboRisk" Width="110" ItemsSource="{Binding Path=CusList,Mode=TwoWay}" SelectedValuePath="{Binding Path=Risk, Mode=OneWay}" SelectedItem="{Binding Mode=OneWay, Path=Risk}">
                                        <ComboBoxItem Content="High" Background="#55A3FF" IsEnabled="False" Margin="1,2,0,0" />
                                        <ComboBoxItem Content="Test Time" Margin="8,2,4,4" />
                                        <ComboBoxItem Content="Yield Hit" Margin="8,2,4,4" />
                                        <ComboBoxItem Content="Quality Impact (DPPM/Reli)" Margin="8,2,4,4" />
                                        <ComboBoxItem Content="Breaking Download" Margin="8,2,4,4" />
                                        <ComboBoxItem Content="ROM Update" Margin="8,2,4,4" />
                                        <ComboBoxItem Content="Low" Background="#55A3FF" Margin="1,2,0,0" IsEnabled="False" />
                                        <ComboBoxItem Content="Good to go" Margin="8,2,4,4" />
                                    </ComboBox>
                                </Grid>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>

在后面的代码中我这样做:

   ComboRisk.SelectedItem = bcomstask.Risk.ToString()
4

1 回答 1

0

这工作正常。

int intCounter = 0;
            foreach(ComboBoxItem currentItem in cboCategory.Items)
            {
                if (currentItem.Content.ToString() == "Time Out")
                    break;
                intCounter++;
            }
            cboCategory.SelectedIndex = intCounter;
于 2013-08-12T09:47:30.323 回答