From 7404b6bd2d2255fc49b200bcc93fd8304e499cd9 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Fri, 27 Apr 2018 10:26:17 -0400 Subject: [PATCH] Fix crash when trying to filter an empty PropertyGrid --- Torch/Views/PropertyGrid.xaml | 2 +- Torch/Views/PropertyGrid.xaml.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Torch/Views/PropertyGrid.xaml b/Torch/Views/PropertyGrid.xaml index 273c84f..78b24d5 100644 --- a/Torch/Views/PropertyGrid.xaml +++ b/Torch/Views/PropertyGrid.xaml @@ -17,7 +17,7 @@ - + diff --git a/Torch/Views/PropertyGrid.xaml.cs b/Torch/Views/PropertyGrid.xaml.cs index 4d44340..9e0bd39 100644 --- a/Torch/Views/PropertyGrid.xaml.cs +++ b/Torch/Views/PropertyGrid.xaml.cs @@ -49,12 +49,14 @@ namespace Torch.Views if (e.NewValue == null) { ScrollViewer.Content = null; + TbFilter.IsEnabled = false; return; } var content = GenerateForType(e.NewValue.GetType()); content.DataContext = e.NewValue; ScrollViewer.Content = content; + TbFilter.IsEnabled = true; } public Grid GenerateForType(Type t) @@ -274,6 +276,8 @@ namespace Torch.Views { var filterText = ((TextBox)sender).Text; var grid = (Grid)ScrollViewer.Content; + if (grid == null) + return; foreach (var child in grid.Children) { if (!(child is TextBlock block))