Browse Source

remove need for reactiveCommand.

pull/2777/head
Dan Walmsley 7 years ago
parent
commit
fc1e033cc4
  1. 1
      src/Avalonia.Dialogs/Avalonia.Dialogs.csproj
  2. 2
      src/Avalonia.Dialogs/Internal/ManagedFileChooser.xaml
  3. 26
      src/Avalonia.Dialogs/Internal/ManagedFileChooserViewModel.cs

1
src/Avalonia.Dialogs/Avalonia.Dialogs.csproj

@ -12,6 +12,7 @@
<Import Project="..\..\build\Rx.props" />
<Import Project="..\..\build\ReactiveUI.props" />
<Import Project="..\..\build\BuildTargets.targets" />
<ItemGroup>
<ProjectReference Include="..\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />

2
src/Avalonia.Dialogs/Internal/ManagedFileChooser.xaml

@ -39,7 +39,7 @@
</dialogs:ChildFitter>
<TextBox x:Name="Location" Text="{Binding Location}" Margin="0 0 5 0">
<TextBox.KeyBindings>
<KeyBinding Command="{Binding EnterLocationCommand}" Gesture="Enter"/>
<KeyBinding Command="{Binding EnterPressed}" Gesture="Enter"/>
</TextBox.KeyBindings>
</TextBox>
</DockPanel>

26
src/Avalonia.Dialogs/Internal/ManagedFileChooserViewModel.cs

@ -145,20 +145,20 @@ namespace Avalonia.Dialogs.Internal
Navigate(directory, (dialog as FileDialog)?.InitialFileName);
SelectedItems.CollectionChanged += OnSelectionChangedAsync;
EnterLocationCommand = ReactiveCommand.Create(() =>
{
if (Directory.Exists(Location))
{
Navigate(Location);
}
else if (File.Exists(Location))
{
CompleteRequested?.Invoke(new[] { Location });
}
});
}
public void EnterPressed ()
{
if (Directory.Exists(Location))
{
Navigate(Location);
}
else if (File.Exists(Location))
{
CompleteRequested?.Invoke(new[] { Location });
}
}
private async void OnSelectionChangedAsync(object sender, NotifyCollectionChangedEventArgs e)
{
if (_scheduledSelectionValidation)
@ -329,7 +329,5 @@ namespace Avalonia.Dialogs.Internal
{
CompleteRequested?.Invoke(new[] { item.Path });
}
public ReactiveCommand<Unit, Unit> EnterLocationCommand { get; }
}
}

Loading…
Cancel
Save