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 a WPF renderer for Xamarin.Forms #486

Closed
mattleibow opened this issue Apr 11, 2018 · 29 comments · Fixed by #917
Closed

Add a WPF renderer for Xamarin.Forms #486

mattleibow opened this issue Apr 11, 2018 · 29 comments · Fixed by #917

Comments

@mattleibow
Copy link
Contributor

mattleibow commented Apr 11, 2018

VS bug #727963

@mterwoord
Copy link

Not trying to push you or rush you, but any eta on this, or semi-working preview nuget packages?

@mattleibow
Copy link
Contributor Author

This is going to be a bit harder to do since I will have to update to Xamarin.Forms v3.0. This is mostly fine, but the packaging is going to be tougher. If I update to v3.0, then so does everyone else who uses SkiaSharp with Xamarin.Forms.

I might create a new set of preview packages that target v3.0, and then when we get further on in life, I will update the existing package. But this makes life harder for everyone.

Also, I just added Tizen support, which appears to only support v2.5.0.

But, after all this, I can start a new branch and just upgrade to v3.0 for the world and hope something happens which will make life easier - maybe Tizen updates, maybe everyone does :)

@mterwoord
Copy link

You updating to XF3 is per project right?

For the world to update to xamarin forms 3, well, isn't that how things just work? if people want to stay on entity framework core, you have to be careful as well...

@mterwoord
Copy link

I mean, do you have things working for XF3? If so, what's the way to get things usable with XF3?

@mterwoord
Copy link

In the meantime, maybe could you make ISKCanvasViewController public? That way I can implement it myself..

@DuncWatts
Copy link

I see there's some WPF work included in the dev/forms-v3 branch, do you happen to know the status of this with WPF? I'm currently trying to investigate the feasibility of adding a WPF client so happy to work with an unfinished build for now if it can get me started with the basics.

@mterwoord
Copy link

@DuncWatts To me it seems, that if the ISKCanvasViewController interface was public, the actual work needed for xamarin forms support is minimal (matter of 2-3 event handlers that need hooking up)

@mattleibow Maybe you can shed a light here?
I'm not even interested in using the wpf client as a real target, just as a development aid..

@mattleibow
Copy link
Contributor Author

mattleibow commented May 17, 2018

I created a PR that makes those types public so additional platforms can be added: #522

This should be in the v1.60.1 release.

@mattleibow
Copy link
Contributor Author

The dev/forms-v3 branch is a total hack that I will soon delete. I am probably going to move to Forms v3.0 after the v1.60.1 release. I hope to support one last v2.5.x version of Forms and then migrate.

I had a chat to the Tizen guys, and I didn't realize that Forms 3.0 has the Tizen types built in, so that makes life much easier.

@mterwoord
Copy link

Awesome!

Regarding v3 etc. It seems that the v2 packages work fine there, just not for WPF (obviously)...

I could hack it together with reflection, but that's not worth it for me, so I'll wait for the v1.60.1 release then.
Thanks for the info!

@mattleibow
Copy link
Contributor Author

The backwards compat info is good news.

@mattleibow
Copy link
Contributor Author

mattleibow commented May 21, 2018

I merged #522 so adding additional renderers should be much easier - until I manage to add them to the official repo.

If you do get a nice version, a PR is always welcome ;)

@mattleibow
Copy link
Contributor Author

No WPF renderer just yet, but you should be able to quickly whip up your own now that the interfaces are all public: https://github.com/mono/SkiaSharp/releases/tag/v1.60.1

I created a test renderer for GTK#, and all I had to do was copy this code into my project and add a #if for GTK#:
https://github.com/mono/SkiaSharp/blob/v1.60.1/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Native.Shared/SKCanvasViewRendererBase.cs

Then I added this for GTK#:
https://github.com/mono/SkiaSharp/blob/v1.60.1/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.UWP/SKCanvasViewRenderer.cs

@mattleibow
Copy link
Contributor Author

@mterwoord, I hope this helps.

@mterwoord
Copy link

Works! Only thing I have to figure out for WPF is DPI translation. For me, images get shown now.

@mattleibow
Copy link
Contributor Author

Nice, with some of these things, I just have a look at how Xamarin.Forms does it. For example, I am going to look at how they do touch and do something similar.

@mattleibow
Copy link
Contributor Author

I will be upgrading to Xamarin.Forms 3.0 in the next major release. Work is currently being done in the development branch. The currently open PRs for this update are #570 and #588 .

Once those are merged into development, I will start accepting PRs for the forms 3.0 platforms (gtk/wpf)

@mattleibow mattleibow removed this from the v1.60.3 milestone Jul 26, 2018
@roustan2
Copy link

roustan2 commented Oct 15, 2018

Hello,
touch dont'work in xamarin wpf projects.
any ideas ?
thanks

@vividos
Copy link

vividos commented Nov 21, 2018

I'm trying to port an Xamarin.Forms Android app to WPF, and I'm using SkiaSharp there. Has anyone managed to get the renderer to work? I had some issues compiling the code in the examples above.

@mattleibow
Copy link
Contributor Author

This is something that we will be looking at in the future.

@memsom
Copy link

memsom commented Mar 21, 2019

I've hit a roadblock because the Mapsui.Forms uses SkiaSharp and seems to be using the SKGLViewRenderer for map rendering. Is there a solution in the works for WPF? I can't use UWP as need to support legacy systems. Going to look at their codebase too to see if I can switch the rendering to something else for WPF. I also can happily hack together something with the SkiaSharp.Views.Desktop.SKGLControl is that would work, just not 100% sure that road is the correct one.

Happy to help, but obviously, no expert in this side of things (just using someone else's library...)

@kinosang
Copy link

Nothing shown on WPF with Xamarin.Forms and SKGLViewRenderer, Got Unable to cast object of type 'SkiaSharp.Views.Forms.SKGLViewRenderer' to type 'Xamarin.Forms.IRegisterable' when resize the window.

@mattleibow
Copy link
Contributor Author

Good news folks! Adding WPF as we speak (or as close as we can get) #917

@mattleibow
Copy link
Contributor Author

Just merged the bits. As soon as the build finishes, I'll push the the preview feed: https://nugetized.blob.core.windows.net/skiasharp-eap/index.json

@mattleibow mattleibow added this to the v1.68.1 milestone Nov 21, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.