0

我必须监视网络上的所有帧。为此,我创建了 2 个ListViews,一个用于显示帧名称、dlc、有效负载和时间戳。我有一个事件,当接收到新框架并在框架中进行更新时触发ListView。如果我在 lv 中选择一帧,则第二帧将ListView填充有关所选帧的少量信息。随着该事件的触发和帧有效负载的变化,选定的行和整个第二行都ListView在更新。所有这些工作我只有一个Dispatcher.Invoke,而且似乎GUI随着更新而落后。我应该使用两个调度程序吗?一个用于第一个帧更新,ListView第二个用于另一个ListView? 我应该为它们中的每一个选择什么优先级?目前我正在使用第 6 级,命名为:Loaded。

<ListView ItemsSource="{StaticResource frames}" 
          Grid.Row="0" 
          Margin="0,1,0,1" 
          Name="lvFrames"
          VerticalContentAlignment="Top" 
          ItemContainerStyleSelector="{StaticResource itemSelector}"
          FontSize="12"
          VirtualizingStackPanel.VirtualizationMode="Recycling"
          VirtualizingStackPanel.IsVirtualizing="True"
          BorderThickness="1"
          BorderBrush="Gray" 
          Grid.ColumnSpan="2" 
          SelectionChanged="lvFrames_SelectionChanged">

    <ListView.View>
        <GridView>
            <GridViewColumn Header="Time" DisplayMemberBinding="{Binding Time}" Width="55"/>
            <GridViewColumn Header="Dir" DisplayMemberBinding="{Binding Dir}" Width="40"/>
            <GridViewColumn Header="Id" DisplayMemberBinding="{Binding Id}" Width="40"/>
            <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" Width="125"/>
            <GridViewColumn Header="Dlc" DisplayMemberBinding="{Binding Dlc}" Width="40" />
            <GridViewColumn Header="Data" DisplayMemberBinding="{Binding Data}" Width="150" />
        </GridView>
    </ListView.View>
</ListView>

这是XAML第一个ListView

<ListView ItemsSource="{StaticResource signals}" 
          Grid.Row="0" 
          Margin="0,1,-0.48,0"
          Name="lvSignals"
          VerticalContentAlignment="Bottom" 
          FontSize="12" VirtualizingStackPanel.VirtualizationMode="Recycling"
          VirtualizingStackPanel.IsVirtualizing="True" 
          BorderThickness="1" BorderBrush="Gray" Grid.ColumnSpan="2"
          VerticalAlignment="Stretch">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Signal Name"
               DisplayMemberBinding="{Binding Name}" Width="160" />
                <GridViewColumn Header="Signal Value"
              DisplayMemberBinding="{Binding Value}" Width="100"/>
           </GridView>
       </ListView.View>
   </ListView>

而这一为信号ListView

4

0 回答 0