UWP Adjusting Grid and Other Tools Depending on Resolution - c#

I am creating an app that is going to be put onto a tablet that has a 7 in screen and a resolution of 1280x800. However in the case that we use the app on tablets that have a higher or lower resolution, I would like the entire app to adjust to it accordingly. Is there a way to make my app and all the tools on the page adjust to the resolution of any screen?

Have you tried VisualStateManager? Well, you can learn much about Universal Windows Platform at MVA
Here's the link : https://mva.microsoft.com/en-US/training-courses/windows-10-development-for-absolute-beginners-14541

You can use AdaptiveTrigger to resize or change the layout of your views this feature is only for UWP apps
https://www.microsoft.com/en-gb/developers/articles/week03aug15/designing-with-adaptive-triggers-for-windows-10/
If you are using Windows 8.1 you have 3 projects Windows 8.1(desktop) Windows phone 8.1(Phone) and shared.
You need to create a specific view for each platform with your custom layout .
Maybe if you need to detect the resolution and effective pixels to do something special
var bounds = Window.Current.Bounds;
double height = bounds.Height;
double width = bounds.Width;
With this information can modify your controls depending of the width or height of the screen.
Best Regards

Related

Unity Game doesn't fit android screen

I was just testing my android app tonight when I found out that the app doesn't match the phone size.
I made the app specifically for my Android Phone ( SAMSUNG S8 ), with a resolution of 1440 x 2960, and yet when loading the app on the phone, it looks way bigger.
Any fixes to this?
set the Ui Scale Mode as Scale With Screen Size.
also, install the phone Devices simulator package to see the phone preview on Unity, It does not have to export your project just to see the preview
check this out
https://docs.unity3d.com/Packages/com.unity.device-simulator#2.2/manual/index.html
You could try to set the screen ratio. When I had this issue it was due to a ratio issue.
In the Player Settings (Ctrl+Shift+B), set the screen width and Height you needs.
In the Supported Aspect Ratio section, I chose Others.
From the upper-left corner of the game preview window.

W8.1 UWP / Xaml WebView rendering small on High DPI Screens

We have an issue on our windows store app, it uses a WebView to display custom generated html from the filesystem. The app is written in WPF / Xaml and so the native UI components scale automatically depending on what the user has set their screen scaling to - however the embedded WebView does not - meaning on my laptop's 4k screen, the WebView font is incredibly tiny. At the moment we have to support windows 8.1 so we are compiling for that target - which means we are embedding a IE11 instance. I thought setting the browser zoom level may be a short term solution but it ends up with horizontal scroll bars on the main window so that's a no go.
I found a MSDN article which shows there is a problem with the underlying COM component not automatically being notified of the high DPI awareness of the app it's being embedded within. The article shows how to get around the issue by overriding what flags the component is sent. However upon going down that route, it seems the WebView that is available on the UWP platform is abstracted even further and you cant grab the instance of the Document MSHTML object needed for the above fix to work.
I also noticed this answer which seems to infer there's a scale factor conflict between windows 8.1 apps and the windows 10 OS, but I am unable to locate any more information on that particular issue.
Any advice would be most welcome as I can't imagine what we're doing is that rare.
Thanks
Turns out this is caused by a combination of factors:
We are using Bootstrap 3, which sets the root HTML font size to 10px, and as IE WebView (Even Edge) uses font size adjustments to deal with DPI scaling, having a base font size set disables this functionality.
Windows Apps which target Windows 8.1 have a maximum scaling of 200% (as that was the maximum supported at the time). However Windows 10 increased this limit to iirc 400%. My laptop screen is set to 250% as it's 4k but when I put a windows 8.1 app onto it, the maximum they go to is 200% so there is a slight size reduction there as well.
I still think this is a fairly serious issue in the Windows Store WebView control as if I open up the bootstrap site in standard edge, it is fine. Even if I do the same with IE11, the page content looks OK even if IE11 itself does not handle DPI at all.

Windows Phone 8.1 Font and Images for Multiple screen sizes

I am new to Windows Phone development, So my first question is :
In android we use sp when setting font size so that it sized according to its phone settings and screen size. But in windows phone I am setting font size in just a number like fontsize="16", Will it adjust itself or I have to do something else for it.
Just like that in android we have ldpi,mdpi,hdpi etc folders for multiple screen density images. In windows how can this be acheived? I have searched for this link but couldn't understand that article.
You can just use a single value for font sizes (and any other "pixel" sizes in XAML) and the platform will do the right thing so that the item is the correct physical size (uses the appropriate number of raw device pixels). The multiplier used for this is RawPixelsPerViewPixel although you don't need to worry about that detail if all you're doing is using text and static graphics (it's useful for things like DX interop, or dynamically downloading images from the network).
For how to provide images of different sizes, look into this MSDN sample.

Button didn't change its size based on the screen resolution

How can I make my Windows Store App look great on large resolutions? For example a Button - how can I change its font size based on the resolution? If I view my app on 13" the button looks OK, but if I view it on 27" display it looks very, very small. Isn't something to be used in the Windows store apps framework to adapt a button, textBlock, etc to the screen resolution?
Set StretchDirection="Both" & StretchProperty="Fill" in ViewBox
This is a consequence of screen scaling based on DPI... which makes your button the same physical size on both monitors, but totally ignores the fact that the user sits/stands much closer to one than the other. Maybe someday we'll have a not-stupid scaling scheme that works based on subtended angles.
Large format monitors already have larger pixels, I suggest you simply opt out of display scaling in your application. (But do respect the global system font size settings)
I'm not sure what the opt-out setting is in XAML (WPF), but in WinForms, I'd be changing the AutoScaleMode property.

Screen resolution detection in Windows 8 Apps

Is there a way I can detect the resolution of the screen in a Windows 8 app so that I can scale and resize the elements of the UI accordingly?
If not then what is the best way to go about developing an app that is resolution independent? Is there a standard way that I am not aware of or is there some other way this can be achieved?
Anything that inherits from FrameworkElement has a SizeChanged event. This event returns the current size of the framework element.
To get the overall size of the screen you can use:
Windows.UI.Xaml.Window.Current.Bounds.Height
Windows.UI.Xaml.Window.Current.Bounds.Width
Be careful as this will return the size of the screen and you will need to take into account whether your app is full-screen or Snapped/Filled.
Microsoft guidance says that you should be avoiding absolute values for height/width and simply setting HorizontalAlignment and VerticalAlignment to Stretch to allow the UI to take as much space as it needs to render.
Anything these two articles don't explain?
Guidelines for scaling to screens (Windows Store apps)
Building Windows 8 : Scaling to different screens
Windows.Graphics.Display.DisplayProperties.LogicalDpi

Categories