Tried countless different variations of this but everything blocks the UI.
My XAML View code:
<TextBox x:Name="FilterText"
materialDesign:HintAssist.Hint="Filter"
cm:Message.Attach="[Event KeyDown] = [Action FilterAsync($eventArgs)]"/>
My ViewModel code:
public async void FilterAsync(KeyEventArgs keyArgs)
{
await Task.Run(() => Filter(keyArgs));
}
public void Filter(KeyEventArgs keyArgs)
{
if (keyArgs.Key != Key.Enter)
{
return;
}
FilteredTreeItems = new ObservableCollection<TreeNode>(TreeItems
.Select(x => x.Search(node => node.Name.Contains(FilterText))).ToList());
}
Search is a recursive function that walks through all of the children nodes of TreeNode. I also have a similar problem although the solution might not be the same which I addressed in my previous post. I'm making another post as I did not address that I'm using Caliburn.Micro in the previous one as I didn't think it can be fault of the Caliburn.micro framework. I also included a more trivial example here with all the code.