WPF integration

Hello, I’m evaluating how to integrate Auth0 into our product suite. Our first priority is a Windows WPF desktop program, which seems unfortunate as I have been trawling through the forums and documentation on how to proceed, but there is little information related to desktop programs. As others have posted, the WPF login behaviour is to popup a Window containing Lock and there is no way to control the position or size of the Window. The effect is amateurish and jarring and unsuitable for production. I can’t find any clues in the source code (which doesn’t match the library) or the public properties of any classes involved that allows me to alter the behaviour.

Is there a way of integrating the login UI and process more closely into a WPF app? For example, could I embed the Lock control inside a browser control inside a control to make it feel like a part of the program? Or can I at least get a handle to the floating Window to control it?

Any guidance on this would be greatly appreciated, as it’s make-or-break in the evaluation process. I only have bare basic experience with Auth0 but I have decades of general development experience, so please use auth0 related jargon with care until I become more familiar with the framework.

Thanks, Greg

We indeed have support for WPF, and it is pretty straight forward using our Auth0 OIDC Client. Please see our WPF / WinForms Quickstart which shows you how to integrate Auth0 into a WPF application:

Hi Jerrie, I found that example recently, but there must be a misunderstanding, as that demo has the exact behaviour that caused me to make my original post: the Lock opens in a separate floating Window over which I have no control. The effect is terribly disruptive.

I looked at source code, I hit breakpoints and looked at properties, etc, but I can’t find any way of altering the behaviour.

Several months ago I used Auth0 Lock in a simple demo Xamarin Forms phone app and it integrated nicely and filled the screen. It felt like a natural part of the app’s navigation. So in the WPF program I want a similar effect. If could at least embed the login UI inside a WPF control then I could place it anywhere in a XAML page and make it feel like a part of the program. Can I do that somehow?

Or have I misunderstood and the Quickstart does what I want, but I have to tweak it somehow that’s not obvious?


You have some options…

  • The Auth0ClientOptions has a Browser property. By default an instance of PlatformWebView gets passed to this. The PlatformWebView constructor has an overload which takes a windowFactory parameter]3.

    So what you can do is to create a new instance of PlatformWebViewbut specify your own windowFactory which instantiates a maximized window. And then set that instance as the value for the Browser property.

  • The second alternative is to implement your own IBrowser class which displays the browser window exactly the way you want to, and then pass an instance of that in the Browser property.

I have run some experiments by modifying the WPF sample. The second alternative you suggest is basically working. The source code for the PlatformWebView provides the important clue about how the WPF Window and Grid parents can be replaced with a user provided Control (I used a Border in my test). I now have Lock appearing inside a Border inside the XAML in a layout position and size of my choosing.

The way the sample code inspects the Uri in the browser’s LoadCompleted event to know when to return Success is rather obtuse.

I will later package what I have learned into a tidy control or sample and reply here with a download Uri. I know where are other people who need a login UI that integrates more smoothly into their Windows desktop programs.

Thanks for your concise advice that finally led to a way forward on this.


Glad to hear you are sorted. It would be great if you can create a standalone sample of this. You can post it here, or if you want to you can submit a PR to this repo:

Just fork that repo, add your sample to the Samples folder, and submit the PR.
Whichever way is easiest for you :slight_smile:

Hi Jerrie, can I bother you with one more question on this issue? I’ve implemented IBrowser and have control over where and how Lock appears, but I can’t figure out how to customise its appearance. Can I somehow intercept and change the Lock Configuration Options in code? Or can I customise from somewhere in my client settings? (and do I need more than a free account to do that?)

Thanks Greg

Please ignore my previous reply asking how to customise the Lock in my WPF scenario. After browsing around in my Dashboard I eventually discovered what Hosted Pages are for. The name is a bit misleading, and the customisation process is confusing, as it’s hard to tell which client page is being customised. In HTML view no client can be selected, then when you switch to Preview a client picker appears, but it doesn’t seem possible to customise different clients as they share the same HTML. Despite that, I seem to have found a way of customising my WPF app client login page via the Dashboard, which is a process that’s external to and independent of my code.

Yeah, the Hosted Pages section is where you can change to look of the Auth0 lock screen.

Please delete this 3rd party spam.

Taken care of, thanks @gfkeogh