question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add WPF, WinForms, Mac nodes to samples

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
bugQcommented, 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.

1reaction
charlesroddiecommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simple data app with WPF and Entity Framework 6
Right-click on the project node in Solution Explorer and choose Add > New Item. In the left pane, under the C# node, choose...
Read more >
Embed WPF User Controls in WinForms Applications
In the Solution Explorer of the project, right-click on the project node and select Add->New Item. Select UserControl (WPF) and create your own ......
Read more >
How to make WPF TreeView style as WinForms TreeView?
Let me answer my own question. WPF TreeView: Original Style WPF TreeView: WinForms Style. Code. All you need to do is a XAML...
Read more >
Will Flutter or React Native overtake WPF and/or Winforms?
39 votes, 84 comments. I have been a hardcore .NET developer for about 5 years now, focusing on Windows App development using Winforms....
Read more >
Revit WPF Add-Ins and Template
The only downside seems to be that many existing samples in the Revit SDK and elsewhere use WinForms. That said, the Revit IFC...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found