Skip to content

Commit

Permalink
Merge pull request #1 from sleepyfran/main
Browse files Browse the repository at this point in the history
Make Elmish.Avalonia work on non-Windows systems
  • Loading branch information
JordanMarr authored Feb 19, 2023
2 parents 746c00f + 098a085 commit 5e4a117
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/Elmish.Avalonia/Command.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ type internal Command(execute, canExecute) =
let mutable _handler = Unchecked.defaultof<EventHandler>
member this.AddRequeryHandler () =
let handler = EventHandler(fun _ _ -> this.RaiseCanExecuteChanged())
CommandManager.RequerySuggested.AddHandler handler
// CommandManager doesn't seem to be available outside of Windows, sample works without it but I suppose I can't just remove it :^)
// CommandManager.RequerySuggested.AddHandler handler
_handler <- handler

member this.RaiseCanExecuteChanged () = canExecuteChanged.Trigger(this, EventArgs.Empty)
Expand Down
5 changes: 2 additions & 3 deletions src/Elmish.Avalonia/Elmish.Avalonia.fsproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="'$(Configuration)' != 'Debug'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net6.0-windows;netcoreapp3.1;net480</TargetFrameworks>
<UseWpf>true</UseWpf>
<TargetFrameworks>net6.0;netcoreapp3.1;net480</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/Samples/AvaloniaExample/App.axaml.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type App() =

override this.Initialize() =
// Initialize Avalonia controls from NuGet packages:
let dataGridType = typeof<System.Windows.Controls.DataGrid>
let _ = typeof<Avalonia.Controls.DataGrid>

AvaloniaXamlLoader.Load(this)

Expand Down
7 changes: 3 additions & 4 deletions src/Samples/AvaloniaExample/AvaloniaExample.fsproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

Expand Down Expand Up @@ -33,7 +32,7 @@
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview5" />
<PackageReference Include="Elmish.Avalonia" Version="1.0.0-alpha-2" />
<ProjectReference Include="..\..\Elmish.Avalonia\Elmish.Avalonia.fsproj" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
</ItemGroup>

Expand Down

0 comments on commit 5e4a117

Please sign in to comment.