0

我有一个包含大约 500 个 ListBox 项的简单 ListBox。我在一个项目上有 2 个组合框。

我的问题是:当我向下滚动时,我会丢失所有 SelectedItem 绑定数据。

我试图将 Virtualizingstackpanel 替换为 Stackpanel,但它会占用我所有计算机的 RAM。所以我需要让它与 Virtualizingstackpanel 一起工作。

问题是:如何将所选项目绑定到它们在 listboxItems 上的组合框?

编码:

<DataTemplate x:Key="MyViewTemplate6">
    <Grid Height="110" Width="480" Margin="10" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <ComboBox HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" ItemTemplate="{StaticResource TypeTemplate7}" ItemsSource="{Binding Types}" SelectedItem="{Binding Type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
    </Grid>
</DataTemplate>

这是在我的 ListBox 中的 ItemTemplate 中。

4

0 回答 0