-
Notifications
You must be signed in to change notification settings - Fork 710
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
How to get screen bounds and change cursors in WinUI3 Desktop applications? #4152
Comments
@anawishnoff do we have documentation for this somewhere? @JesseCol Do you know how to do this? |
I think the new WinUI 3 Window API has guidance for those functions that call "GetForCurrent" and "CoreWindow" |
@marb2000 , do you have a recommendation here? Thanks! |
For the Cursor, there is a new API for this: Microsoft.UI.Xaml.UIElement
{
protected CoreCursor ProtectedCursor { get; set; }
} You can set this property and it will handle it all for you. The only problem is that you need to have a subclass of UIElement to access it. For DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel, you need to get the XamlRoot.RasterizationScale. |
Hi Team, |
@azchohfi many thanks for the valuable hint! This replaces 'Windows.UI.Core.CoreWindow.GetForCurrentThread().PointerCursor' for me. But it would be very nice if |
@jschwizer99 @KanniyappanP and @KarthikRajaAKR it seems that your question was resolved. I'm closing this issue. Feel free to reopen it in case we miss something related or open a new one. Thanks! |
Hi @marb2000 I've tried ProtectedCursor API from UIElement as you suggested instead of using from CoreWindow (CoreWindow.GetForCurrentThread().PointerCursor), but it doesn't change the cursor pointer. I have used like below. but not working for me.
Thanks., |
I had the same experience of using Firstly I can confirm that The issue I found was as part of the action setting the cursor, I was also I would recommend you go back to small steps, just set the cursor with no other side affects, convince yourself that it works and then build up the functionality you want and find out where the conflict occurs. Another thought is that you might find that your action is fully synchronous and never yields the thread to change the pointer. You might try inserting a Hope that helps, best of luck ... |
I need to achieve below requirements in WinUI 3 Desktop environment.
How to get display screen bounds?
How to change windows cursor type in desktop environment?
I already did this in WinUI UWP applications.
For Screen bounds,
var visibleBounds = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds; var scaleFactor = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; Size screenSize = new Size((visibleBounds.Width scaleFactor), (visibleBounds.Height scaleFactor));
For Cursor:
Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.SizeNorthwestSoutheast, 0);
Anyone please suggest how to achieve same requirement in WinUI Desktop applications?
The text was updated successfully, but these errors were encountered: