diff --git a/MaterialDesignExtensions/Controls/FileSystemControl.cs b/MaterialDesignExtensions/Controls/FileSystemControl.cs index 7a7a22db..f8e6c8e0 100644 --- a/MaterialDesignExtensions/Controls/FileSystemControl.cs +++ b/MaterialDesignExtensions/Controls/FileSystemControl.cs @@ -399,7 +399,11 @@ public override void OnApplyTemplate() protected virtual void LoadedHandler(object sender, RoutedEventArgs args) { m_controller.PropertyChanged += ControllerPropertyChangedHandler; - m_currentDirectoryTextBox.KeyDown += CurrentDirectoryTextBoxKeyDownHandler; + + if (m_currentDirectoryTextBox != null) + { + m_currentDirectoryTextBox.KeyDown += CurrentDirectoryTextBoxKeyDownHandler; + } // not sure if the control should get keyboard focus on loading //Keyboard.Focus(this); @@ -408,7 +412,11 @@ protected virtual void LoadedHandler(object sender, RoutedEventArgs args) protected virtual void UnloadedHandler(object sender, RoutedEventArgs args) { m_controller.PropertyChanged -= ControllerPropertyChangedHandler; - m_currentDirectoryTextBox.KeyDown -= CurrentDirectoryTextBoxKeyDownHandler; + + if (m_currentDirectoryTextBox != null) + { + m_currentDirectoryTextBox.KeyDown -= CurrentDirectoryTextBoxKeyDownHandler; + } } protected void OpenSpecialDirectoriesDrawerCommandHandler(object sender, ExecutedRoutedEventArgs args) @@ -424,7 +432,7 @@ protected void SwitchPathPartsAsButtonsHandler(object sender, ExecutedRoutedEven private void CurrentDirectoryTextBoxKeyDownHandler(object sender, KeyEventArgs args) { - if (args.Key == Key.Enter) + if (sender == m_currentDirectoryTextBox && args.Key == Key.Enter) { string directory = m_currentDirectoryTextBox.Text .Replace("\n", string.Empty) @@ -541,7 +549,11 @@ protected virtual void CurrentDirectoryChangedHandler(string newCurrentDirectory try { m_controller.SelectDirectory(newCurrentDirectory); - m_currentDirectoryTextBox.Text = newCurrentDirectory; + + if (m_currentDirectoryTextBox != null) + { + m_currentDirectoryTextBox.Text = newCurrentDirectory; + } } catch (PathTooLongException) { diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 6880220b..902ebd87 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -197,3 +197,4 @@ Please change your configuration according to [App.xaml](https://github.com/spie #### Fixes * Fixed reflection code in `ResourceDictionaryExtensions` * Fixed usage of `SecondaryHueMidBrush` and `SecondaryHueMidForegroundBrush` resources +* Fixed `NullReferenceException` in `FileSystemControl` diff --git a/docs/snippets/releasenotes.html b/docs/snippets/releasenotes.html index dd6ca567..9dddc5d3 100644 --- a/docs/snippets/releasenotes.html +++ b/docs/snippets/releasenotes.html @@ -32,6 +32,8 @@

Features

Fixes

v3.2.0

Features

@@ -54,7 +56,6 @@

Features

Fixes

v3.1.0

Features