[UWP] TryResizeView() in UWP returns False when Window is dragged to full Screen Height

Md. Niaz Mahmud 171 Reputation points
2021-07-02T20:11:40.587+00:00

I am building an UWP app where, app width need to be expanded while navigation pane is being opened. I have used bool result = ApplicationView.GetForCurrentView().TryResizeView(desiredSize); for resizing app. But when app is dragged to full screen height, to the taskbar, TryResizeView() returns false, though there is space horizontally. desiredSize.Height is set according to Screen Height, and desiredSize.Width is set to my desired width.

What is the problem here?? Or, Is there any other way rather than ApplicationView.GetForCurrentView().TryResizeView() for resizing app in runtime??

For a pictorial explanation, I have used microsoft sample which can represents a similar situation to my app.

111471-tempsnip.png

Developer technologies | Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. AryaDing-MSFT 2,916 Reputation points
    2021-07-06T08:18:41.403+00:00

    Hi,

    Welcome to Microsoft Q&A!

    I see you have the available width to expand. My meaning is that you need to check whether the Size.Height also meet condition. Maybe your Size.Width is right, how about Size.Height? Only both size.Height and size.Width are correct, this method returns true.

    You mentioned you used Screen height as Size.Height, but the available height is less than the Screen height. For example, if display resolution is 1920*1080 and scale is 150%, available work area is 1280 * (720 - taskbarheight). Therefore, the size.height need to be smaller than (720 - taskbarheight), and size.width need to be smaller than 1280.

    In a word, you need to set your desiredSize.Height and desiredSize.Width to be less than available area according to the display resolution and scale.


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.