CollectionViewSourceのSourceにListをBindingしています。
フィルターを実行したいときはIsLiveFilteringRequestedを切り替えます。
ただ、UIのDispatcherでCollectionViewSourceが動いてしまうため、Itemの数が多いとUIが長時間操作できなくなります。
CollectionViewSourceをワーカースレッドで処理させる方法はありますか。
view
<CollectionViewSource x:Key="col" IsLiveFilteringRequested="{Binding IsLiveFilteringRequested}" Source="{Binding AlertDatas}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Filter"> <ei:CallMethodAction TargetObject="{Binding}" MethodName="AlertDataFilter"/> </i:EventTrigger> </i:Interaction.Triggers> </CollectionViewSource>
view model
public class VMDL : System.ComponentModel.INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged = delegate { }; bool mIsLiveFilteringRequested; public bool IsLiveFilteringRequested { get => mIsLiveFilteringRequested; set { mIsLiveFilteringRequested=value; PropertyChanged?.Invoke(this,new PropertyChangedEventArgs(nameof(IsLiveFilteringRequested))); } } public System.Collections.ObjectModel.ObservableCollection<object> AlertDatas { get; set; } public void AlertDataFilter(object sender, FilterEventArgs e) { //フィルター処理 } void ExeFilter() { System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => { IsLiveFilteringRequested = true; IsLiveFilteringRequested = false; }}); } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。