Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WPF, WinForms, Mac nodes to samples #55

Closed
dsyme opened this issue May 18, 2018 · 16 comments
Closed

Add WPF, WinForms, Mac nodes to samples #55

dsyme opened this issue May 18, 2018 · 16 comments
Labels
up-for-grabs The issue is up-for-grabs

Comments

@dsyme
Copy link
Collaborator

dsyme commented May 18, 2018

From slack discussion with @charlesroddie and @mydogisbox

The pre-release of Xamarin.WPF is just out. It seems to be usable with glitches here or there as you would expect. It has all the stock controls in Xamarin.Forms. There is almost no support in 3rd party controls at the moment. (edited)

Let's add a sample under https://github.com/fsprojects/Elmish.XamarinForms/tree/master/Samples/CounterApp

I'd like to also see WinForms and Mac nodes under there.

Here's a sample from @mydogisbox:


type CounterApp () as app = 

    inherit Application ()
    let program = Program.mkProgram App.init App.update App.view
    let runner = 
        program
        |> Program.withConsoleTrace
        |> Program.withDynamicView app
        |> Program.run
 

type MainWindow() as this =
    inherit FormsApplicationPage()

    do Forms.Init()
    do this.LoadApplication(new CounterApp())


[<STAThread>] 
[<EntryPoint>]
do (new System.Windows.Application()).Run(MainWindow()) |> ignore
@dsyme dsyme added the up-for-grabs The issue is up-for-grabs label May 18, 2018
@dsyme dsyme changed the title Add WPF sample Add WPF nodes to samples May 18, 2018
@dsyme dsyme changed the title Add WPF nodes to samples Add WPF, WinForms, Mac nodes to samples May 18, 2018
@gibranrosa
Copy link

gibranrosa commented May 18, 2018

I was able to get a WPF sample working, but to do this, we have to upgrade Xamarin.Forms in all projects to last stable release 3.0.482510, what do you think about this?
The Android projects with last release work well.

@nosami
Copy link

nosami commented May 18, 2018

I was able to get a WPF sample working, but to do this, we have to upgrade Xamarin.Forms in all projects to last stable release 3.0.482510, what do you think about this?

Seems sensible to me. We upgraded all the templates (apart from F#, I didn't have the time 😞 ) to XF 3.0

@gibranrosa
Copy link

And with WinForms I haven't notice before, but the Aosoft's library has no Nuget package, we would have to do it another way. 😢

@dsyme
Copy link
Collaborator Author

dsyme commented May 18, 2018

I was able to get a WPF sample working, but to do this, we have to upgrade Xamarin.Forms in all projects to last stable release 3.0.482510, what do you think about this? The Android projects with last release work well.

Do you need to update the Xamarin.Forms.Core in the "neutral" group? That's the one we build Elmish.XamarinForms.dll against. I would prefer that keeps the lowest dependency possible, e.g. to allow us to use it with as many 3rd party components as possible. The Android, iOS and WPF projects (e.g. anroidapp group in pakt.dependencies) can all run with XF latest.

My understanding is that XF is binary compat, so this approach should work?

@dsyme
Copy link
Collaborator Author

dsyme commented May 18, 2018

I was able to get a WPF sample working, but to do this, we have to upgrade Xamarin.Forms in all projects to last stable release 3.0.482510, what do you think about this? The Android projects with last release work well.

Could you send a PR for this so I can take a look? Thanks!

@gibranrosa
Copy link

There it is: #56

But, if there is 2 versions of Xamarin.Forms in the same solution there is even a message warning about this in the build.

@mydogisbox
Copy link

I added WPF to the AllControls sample without any material changes to other parts of the sample (including upgrading Xamarin.Forms in other projects). Some of the other projects don't build on my machine but considering I didn't change any of them I assume they continue to work.

WPF Sample

@nosami
Copy link

nosami commented Jun 12, 2018

I just added a MacOS version of the Elmish.Calculator. The code is almost identical to the iOS version.

image

@bugQ
Copy link

bugQ commented Jul 2, 2018

Could we target UWP also? I know I'd have use for it.

@bugQ
Copy link

bugQ commented Jul 2, 2018

Oh, I traced the trail of breadcrumbs to dotnet/corert#5780, and can see that question might be premature.

@charlesroddie
Copy link

charlesroddie commented Jul 2, 2018

Please add that @bugQ . Getting this running is easy, except release to store which is in testing.

You can add a UWP project, min Windows version FCU. Put xmlns:forms="using:Xamarin.Forms.Platform.UWP" inside <Page> tags in MainPage.xaml. Put Xamarin.Forms.Forms.Init(e); after the rootFrame instructions in App.xaml.cs. Installing the relevant nuget packages. Put LoadApplication(new AppName.App()); after this.InitializeComponent(); in MainPage.xaml.cs, after adding the appropriate project reference.

You can also copy over from a C# Xamarin.Forms template if you prefer.

You can then run in debug mode, and test in release mode using the instructions in the thread you linked.

You'll need to do this for each of the samples.

@bugQ
Copy link

bugQ commented Jul 3, 2018

Thanks for the encouragement and instructions, @charlesroddie. After referencing sample Xamarin.UWP projects and figuring out that there was one missing step (changing the class of the <Page> element to <forms:WindowsPage>), I was able to get something working, although it occasionally throws an exception on the Xamarin.Forms.Forms.Init(e); line, saying "More data is available." It sounds like this is a Xamarin.UWP bug, probably a failure to loop and read all available data somewhere. I'll track that down and perhaps file a report later, but it doesn't seem to have anything to do with this project.

So, basically, everything is set for UWP, too, at least for local testing. I'll submit a PR shortly.

@xperiandri
Copy link

Thanks @charlesroddie, @bugQ. It works

@bugQ
Copy link

bugQ commented Feb 26, 2019

oh, I actually completely spaced this one. thank @TimLariviere 😅

@xperiandri
Copy link

But what about integration with UWP Frame? Can it be used with Fabulous to switch pages?

@TimLariviere
Copy link
Member

@xperiandri Do you mean navigating from page to page inside the app, or embedding a page in another one?
If it's the first, then NavigationPage does it.
If it's the second, I don't think Xamarin.Forms provides a control which uses Frame behind the scenes, it's not a concept that can be found on other platforms.

If you specifically need to use UWP's Frame control in Fabulous, then you can always implement your own Fabulous extension.
https://fsprojects.github.io/Fabulous/views-extending.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
up-for-grabs The issue is up-for-grabs
Projects
None yet
Development

No branches or pull requests

8 participants