Here in my Receipt and Payments view, I've the EditText and HiBlock to Search, Filter and Highlight content of ICollectionView.

the Text property of EditText is bound to view model's Query property:
string query;
public string Query {
get { return query; }
set {
if (query != value) {
query = value;
Debug.WriteLine("In VM");
RPs.Refresh();
}
}
}
where I refresh the ICollectionView and HiBlock's Query property where I've the logic for highlighting. When I typed a after mr in the EditText, it first printed In VM in the Output window and started printing In HiBlock ... immediately. There wasn't that much entries in the ListBox BUT, looks like, the Query PropertyChangedCallback of HiBlock was invoked for all visible as well as invisible lines (HiBlock) in the ListBox and even though I didn't see/have the invisible HiBlocks in the ListBox, the Visibility property of HiBlock was Visible in the PropertyChanged callback, probably, because it called onQueryChanged in HiBlock and RPs.Refresh() in view model parallelly. Right now, it's very slow.
What I want it do is finish the RPs.Refresh() in the view model first in order to make sure that the Visibility of invisible HiBlocks becomes Collapsed and then perform the highlighting logic only on the Visible HiBlocks.
How to do that?
EDIT
On thing's come to mind is create an extra property in the view model, reset that after refresh and notify, and finally have a relative source binding with HiBlock's Query on that property in the DataTemplate BUT that's a lot of work! Is there any better way?
EDIT
BUT what came to mind, didn't work as I expected:
tried to add another GIF (2.19MB) here BUT couldn't!
When I'd mr in the EditText, there're only 35 Visible HiBlocks in the ListBox, 2 of them Receipt and Payment are not queryable, and when I typed a it'd gotten in to Query PropertyChangeCallback 196 times altogether! In the view model, I've changed newly added HilightQuery after Refresh:
string query;
public string Query {
get { return query; }
set {
if (query != value) {
query = value;
Debug.WriteLine("In VM");
RPs.Refresh();
HilightQuery = query;
}
}
}
string hilightQuery;
public string HilightQuery {
get { return hilightQuery; }
set {
if (hilightQuery != value) {
hilightQuery = value;
OnPropertyChanged(nameof(HilightQuery));
}
}
}
and in the Group ControlTemplate instead of setting Query property directly from EditText, I've this binding
header.SetBinding(HiBlock.TextProperty, new Binding(nameof(GroupItem.Name)));
//header.SetBinding(HiBlock.QueryProperty, new Binding(nameof(EditText.Text)) { Source = querySource, IsAsync = true });
header.SetBinding(HiBlock.QueryProperty, new Binding() {
Path = new PropertyPath("DataContext.HilightQuery"),
RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(ListBox), 1)
});
and in ItemTemplate this:
tenantName.SetBinding(HiBlock.TextProperty, new Binding(nameof(ReceiptPayment.Tenant)));
//tenantName.SetBinding(HiBlock.QueryProperty, new Binding(nameof(EditText.Text)) { Source = querySource, IsAsync = true });
tenantName.SetBinding(HiBlock.QueryProperty, new Binding() {
Path = new PropertyPath("DataContext.HilightQuery"),
RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(ListBox), 1)
});
why does it say HiBlock is Visible and get into the PropertyChangedCallback so many times even though they're clearly Invisible/Collapsed?
