Forum Xamarin Xamarin.Forms

Buttons not working in WPF

I've just added a WPF platform to my project following this tutorial.

Every seems fine with the project, I launch it and my login page shows up as it should. The issue is that my buttons don't work i.e. I click them and the "Pressed" event never fires. I've tested this by printing to the output window which works in UWP but not WPF.

Any help would be greatly appreciated

Answers

  • JuniorJiangJuniorJiang Member, Xamarin Team Xamurai
    edited June 15

    Hi @TheFaceGrabber , you also can refer to this offical steps to setup in project .

    1. In Visual Studio 2019, right-click on the solution name in the Solution Explorer and choose Add > New Project....

    2. In the Add a new project window, select C# in the Languages drop down, select Windows in the Platforms drop down, and select Desktop in the Project type drop down. In the list of project types, choose WPF App (.NET Framework)

    3. In the Configure your new project window, type a name for the project with a WPF extension, for example, BoxViewClock.WPF. Click the Browse button, select the BoxViewClock folder, and press Select Folder to put the WPF project in the same directory as the other projects in the solution

    4. In the Solution Explorer, right click the new BoxViewClock.WPF project and select** Manage NuGet Packages...**. Select the Browse tab, and search for Xamarin.Forms.Platform.WPF

    5. Right click the solution name in the Solution Explorer and select Manage NuGet Packages for Solution.... Select the Updates tab and then select the Xamarin.Forms package. Select all the projects and update them to the same Xamarin.Forms version

    6. In the WPF project, right-click on References and select Add Reference.... In the Reference Manager dialog, select Projects at the left, and check the checkbox adjacent to the BoxViewClock project

    7. Edit the MainWindow.xaml file of the WPF project.

    8. Edit the MainWindow.xaml.cs file of the WPF project.

    9. Right-click the WPF project in the Solution Explorer and select Set as Startup Project.

    However they all work in my local site . You can share a sample project link with Button event here , I will test that .

  • JuniorJiangJuniorJiang Member, Xamarin Team Xamurai

    Hi @TheFaceGrabber , have you sovled this ? If no , you can share a sample project link here . I will check that in my local site :-)

Sign In or Register to comment.