0

我有一个列表框,其中包含一个项目列表,其中每个项目都有一个组合框。 在此处输入图像描述

我遍历列表框中的所有项目,并且我想为列表框中的每个项目获取组合框的选定项目。我怎样才能做到这一点?

我目前如何取出它

private void StartConvertionButton_Click(object sender, RoutedEventArgs e)
{
    RunNextVideo();
}

private void RunNextVideo()
{
    var nextFile = viewModel.Files.Where(x => x.IsWorking == false).FirstOrDefault();
    if(nextFile == null)
        return;

    DeviceQualityModel quality = (DeviceQualityModel) DeviceQualityComboBox.SelectedItem;
    //Subtitle subtitle = nextFile
    var test = FileListBox.Items;

    VideoProcessing videoProcessing = new VideoProcessing(nextFile, ffmpegWrapper, viewModel, quality, new Subtitle());
    videoProcessing.Done += VideoProcessingOnDone;

    var thread = new Thread(videoProcessing.Run);
    threads.Add(thread);
    thread.Start();
}

这是我的 wpf 列表框

<ListBox Grid.Row="1" Margin="0,10,0,0" ItemsSource="{Binding Files, Mode=TwoWay}" x:Name="FileListBox" HorizontalContentAlignment="Stretch">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="100" />
                    </Grid.ColumnDefinitions>

                    <StackPanel Grid.Column="0">
                        <TextBlock Text="{Binding Filename}" FontSize="15" />
                        <StackPanel Orientation="Horizontal" >
                            <TextBlock Text="Width: " FontSize="12" />
                            <TextBlock Text="{Binding Width}" FontSize="12" />
                            <TextBlock Text=" Height: " />
                            <TextBlock Text="{Binding Height}" FontSize="12" />
                        </StackPanel>
                        <TextBlock Text="{Binding Path}" FontSize="9" />
                        <ComboBox ItemsSource="{Binding Subtitles, Mode=TwoWay}"  Visibility="{Binding HaveSubtitles, Converter={StaticResource localVisibilityConverter}}" IsSynchronizedWithCurrentItem="True" SelectedIndex="1">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Language}"/>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                        <ProgressBar Height="10"  IsIndeterminate="True" Visibility="{Binding IsWorking, Converter={StaticResource localVisibilityConverter}}" Width="Auto"/>
                    </StackPanel>

                    <Button Grid.Column="1" Margin="10,0,0,0" Click="RemoveButton_Click">Remove</Button>
                </Grid>
            </DataTemplate>
        </ListBox.ItemTemplate>
4

1 回答 1

0

SelectedItem将您的绑定ComboBox到您的项目上的属性,然后您可以从那里获取它。

于 2013-06-30T11:50:31.980 回答