Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions MaterialDesignExtensions/Controllers/FileSystemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Windows;
using MaterialDesignThemes.Wpf;

using MaterialDesignExtensions.Model;
Expand Down Expand Up @@ -777,10 +777,18 @@ private bool AreObjectsEqual(object o1, object o2)

private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null && !string.IsNullOrWhiteSpace(propertyName))
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
if (!string.IsNullOrWhiteSpace(propertyName))
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
else
{
Application.Current.Dispatcher.InvokeAsync(() =>
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
});
}
}
}
}
20 changes: 9 additions & 11 deletions MaterialDesignExtensions/Controls/BaseFileControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ namespace MaterialDesignExtensions.Controls
/// </summary>
public abstract class BaseFileControl : FileSystemControl
{
/// <summary>
/// An event-handler for the FileSelected event.
/// </summary>
public delegate void FileSelectedRoutedEventHandler(object sender, FileSelectedEventArgs fileSelectedEventArgs);

/// <summary>
/// The name of the combo box inside the template.
/// </summary>
Expand All @@ -38,22 +43,15 @@ public abstract class BaseFileControl : FileSystemControl
/// An event raised by selecting a file.
/// </summary>
public static readonly RoutedEvent FileSelectedEvent = EventManager.RegisterRoutedEvent(
nameof(FileSelected), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(BaseFileControl));
nameof(FileSelected), RoutingStrategy.Bubble, typeof(FileSelectedRoutedEventHandler), typeof(BaseFileControl));

/// <summary>
/// An event raised by selecting a file.
/// </summary>
public event RoutedEventHandler FileSelected
public event FileSelectedRoutedEventHandler FileSelected
{
add
{
AddHandler(FileSelectedEvent, value);
}

remove
{
RemoveHandler(FileSelectedEvent, value);
}
add => AddHandler(FileSelectedEvent, value);
remove => RemoveHandler(FileSelectedEvent, value);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion MaterialDesignExtensions/Controls/FileSystemControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ public FileSystemControl()
: base()
{
m_controller = new FileSystemController();
m_controller.SelectDirectory(CurrentDirectory);

CommandBindings.Add(new CommandBinding(FileSystemControlCommands.OpenSpecialDirectoriesDrawerCommand, OpenSpecialDirectoriesDrawerCommandHandler));
CommandBindings.Add(new CommandBinding(FileSystemControlCommands.SelectDirectoryItemCommand, SelectDirectoryItemCommandHandler));
Expand All @@ -326,6 +325,7 @@ public override void OnApplyTemplate()
{
base.OnApplyTemplate();

m_controller.SelectDirectory(CurrentDirectory);
m_pathPartsScrollViewer = Template.FindName(PathPartsScrollViewerName, this) as ScrollViewer;

m_pathPartsItemsControl = Template.FindName(PathPartsItemsControlName, this) as ItemsControl;
Expand Down