โ Deprecated: Legacy
Suggested alternative: Mvvm.CommonInteractions.WinUI
Common ReactiveUI MVVM Level Interactions(like open/save file) for WPF/UWP/Uno platform โญ Last 10 features: - feat: Added support for empty Extensions array to Open files Interactions of Storage API. 2021-11-04 - feat: Added new file interactions system based on streams. 2021-11-04 - feat: Added BooleanToVisibilityConverter. 2021-11-03 - feat(WPF): Added empty extensions support for FileInteractions. 2021-11-03 - feat: Added ContinuousIntegrationBuild msbuild property. 2021-11-03 - feat: Updated MSBuild.Sdk.Extras to 3.0.38. 2021-10-29 - feat: Lowered required uwp version to 16299. 2021-10-29 - feat: Added PACKAGE_RELEASE_NOTES to description. 2021-10-29 - feat: Lowered ProjectReunion to 0.8.3. 2021-10-29 - feat: Added BaseConverter. 2021-10-29 ๐ Last 10 bug fixes: - fix: Fixed missing Core NuGet package. 2021-11-05 - fix: Try to use explicit targets in CI. 2021-11-05 - fix: Try to use libs target in CI. 2021-11-05 - fix: Fixed Uno DataContext bug. 2021-11-04 - fix: Now SaveFileArguments.Extension is required property. 2021-11-04 - fix: Fixed BaseConverter namespace. 2021-10-30 - fix: Fixed IOExtensions file.Name bug. 2021-10-27 - fix: Fixed uwp ConfigureAwait(false) bugs. 2021-10-27 - fix: Fixed CA1014. 2021-10-27 - fix: Fixed CS8002. 2021-10-27
$ dotnet add package H.ReactiveUI.CommonInteractions.ProjectReunionCommon ReactiveUI MVVM Level Interactions(like open/save file) for WPF/UWP/Uno platform.
Install-Package H.ReactiveUI.CommonInteractions.Core
Install-Package H.ReactiveUI.CommonInteractions.Wpf
Install-Package H.ReactiveUI.CommonInteractions.Uno
Install-Package H.ReactiveUI.CommonInteractions.Uwp
Add to your App constructors:
public sealed partial class App
{
private InteractionManager InteractionManager { get; } = new();
public App()
{
InteractionManager.Register();
// Not necessary. Displays unhandled exceptions using MessageInteractions.Exception.
// InteractionManager.CatchUnhandledExceptions();
// your code
}
}
var data = await FileInteractions.OpenFile.Handle(new OpenFileArguments
{
SuggestedFileName = "my.txt",
Extensions = new[] { ".txt" },
FilterName = "My txt files",
});
var text = data.Text;
var fileName = await FileInteractions.SaveFile.Handle(new SaveFileArguments
{
SuggestedFileName = "my.txt",
Extension = ".txt",
FilterName = "My txt files",
BytesFunc = () => Task.FromResult(Encoding.UTF8.GetBytes(text)),
});
// WPF
xmlns:h="clr-namespace:H.ReactiveUI;assembly=H.ReactiveUI.CommonInteractions.Wpf"
// UWP/Uno
xmlns:h="using:H.ReactiveUI"
<Element
AllowDrop="True"
h:DragAndDropExtensions.DragFilesEnterCommand="{Binding DragFilesEnter}"
h:DragAndDropExtensions.DragTextEnterCommand="{Binding DragTextEnter}"
h:DragAndDropExtensions.DragLeaveCommand="{Binding DragLeave}"
h:DragAndDropExtensions.DropFilesCommand="{Binding DropFiles}"
h:DragAndDropExtensions.DropTextCommand="{Binding DropText}"
>
Command arguments:
DragFilesEnterCommand - FileData[] - Array of files.
DragTextEnterCommand - string - Text.
DragLeaveCommand - null.
DropFilesCommand - FileData[] - Array of files.
DropTextCommand - string - Text.