C# Wpf数据网格滚动条冻结
我是WPF的新手。我有一个数据网格,大约有10000行。要实现搜索和突出显示功能,将实现以下代码C# Wpf数据网格滚动条冻结,c#,wpf,datagrid,scrollbar,C#,Wpf,Datagrid,Scrollbar,我是WPF的新手。我有一个数据网格,大约有10000行。要实现搜索和突出显示功能,将实现以下代码 <Style x:Key="DefaultCell" TargetType="{x:Type DataGridCell}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate Targ
<Style x:Key="DefaultCell" TargetType="{x:Type DataGridCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
<local:CustomTextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Content.Text}">
<!--InlineCollection="{Binding ., Converter={StaticResource StringToXamlConverter} }"/>-->
<local:CustomTextBlock.InlineCollection>
<MultiBinding Converter="{StaticResource StringToXamlConverter}">
<Binding RelativeSource="{RelativeSource Self}" Path="." />
<Binding RelativeSource="{RelativeSource Self}" Path="(local:SearchOperations.SearchTerm)"/>
</MultiBinding>
</local:CustomTextBlock.InlineCollection>
</local:CustomTextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
搜索和突出显示就像一个魔咒。但点击垂直滚动条,整个网格冻结。这里的原因是什么 您可以在
绑定上使用IsAsync
属性
<Binding RelativeSource="{RelativeSource Self}" Path="." IsAsync="True"/>
这将在异步进程进行时提供一个值,典型的值是文本,例如“Loading…”消息。我猜它正在为每一行运行转换器。你能给它一分钟的时间来测试这个理论吗?@MikeEason是的,转换器必须在每个单元格中运行,以实现搜索功能。请参阅此解决方案。谢谢你的解决方案,但不幸的是,它不起作用。我所观察到的是,当我点击网格中的任意位置时,网格将进入无响应状态。但当网格加载时,鼠标滚轮上的行会滚动。
<Binding RelativeSource="{RelativeSource Self}" Path="." IsAsync="True" FallbackValue="..."/>