How to handle screen rotation on windows 8 application - windows

i was wondering how can I handle screen rotations for windows 8 applications using c#?
I want to create several xaml files and just change them every time the screen orientation is changed. Is that even possible?

You can use the Device Window in Visual Studio to record state changes to your UI elements. In the Device Window you can select the other visual states (namely snapped, full screen portrait, full screen landscape, and filled) and then make the changes you need for the desired end state. Those changes are then captured in the VisualStateManager that's part of your XAML file. The obvious benefit here is that "it just works", you don't have to detect orientation state yourself or do any fancy XAML replacements/substitution.
Step 3 of Navigation, layout, and views tutorial has an example of this - granted, it's pretty simplistic, but should get the concepts across.

Open AppManifest file in your project and select the desired orientations .

Related

Automatic window resize using Visual Studio 13

How can I have a window resize automatically to fit the screen on the monitor, using Visual Studio 13 and C#.
Have an application which displays the main window from which you can call up (Fig 1) and individually display different forms to be populated and then submitted.
On some computers, the complete form is shown (Fig 2); however, on a few computers, only about 80% of the page is displayed (Fig3). No side (up/down) scroll bar is displayed, so the users on these computers are unable to scroll up and see the rest of the page. This is occurring on several computer makes and/or models and not limited to a specific make or model. Is there a method to be able to automatically resize the page to fit the screen or to show a scroll bar?
Tried re-imaging an affected computer from scratch, but get the same results. Image is coming from a central area, so don’t believe it’s the software. Other machines are re-imaged with same central image without this problem.
Using Control Panel, tried adjusting the resolution for the monitor with no success, getting the same results. Using a larger monitor does not solve this issue.
Had users use other unaffected computer, and they are able to get the complete screen. Tried users from unaffected machines test affected machines and they are unable to get the complete screen. User account profile is probably not the issue.
I am new to Visual Studio, C# and programming. I am trying to maintain a legacy application and do not want to break the application 90% of users are able to see complete windows. Open to suggestions.
(Fig 1) Main window
(Fig 2) Functioning correctly, what window should look like.
90% of users get this window
(Fig 3) Functioning incorrectly, 10% of users get this window.
Bottom is cut off. No scroll bar
To Use Scroll bars for this purpose you have to select the panel which content is getting hidden and in the properties choose AutoScroll : True
Here is the image

How can to see off screen content at design time in Blend or VS for Windows Phone 7 or 8

I am designing a long Windows Phone 8 page. It is very frustrating that I can't see most of it in the design visuals.
I was wondering if anyone knows a way of being able to see the content visually, at design time, of either the bottom of the page (i.e. scrolling up in the designer), or preferable to be able to see the whole page.
I know you can turn the chrome off, is there any way to turn the view windows masking frame off?
This also applies to trying to see a whole panorama view too!
Thanks
Try temporarily collapsing the controls which are above the controls which is getting off screen. Later you can set that control to required dimensions again.
Instead of removing d:DesignWidth & d:DesignHeight from xaml root tag, just set these values high enough such that all of your content gets displayed.

WinRT Settings Charm. Elements overlayed by on screen keyboard

I'm developing for Windows 8 (WInRT) and have problem with settings charm. Settings popup is based on Microsoft SDK settings charm. Settings panel is Popup. Content is wrapped by ScrollViewer -> Grid -> StackPanel. In StackPanel I have input fields. when I trying to fill last of them on screen keyboard overlaying it and I cant see field and cant scroll to it. Is there any way to see it and to scroll to it automatically?
Seems like the popups on Windows 8 suffer from the same problem as they did on Windows Phone in that when you put a TextBox on one of them - it does not get pushed up together with all the other content as it does when it is not in a popup.
My solution to that would be to not use popup for input fields and instead go for a layout that you can manage yourself.
By default the app has a Frame control at its visual root. You can modify it for example by putting your own UserControl in there (I usually call it AppShell) which has the Frame used by all pages, you can have a layer for popups, log in screens, the extended splash screen etc.
To solve your problem you would need to put your charm's UI inside of such layer instead of in a popup. Then the build-in mechanism that pushes all the UI up when the on-screen keyboard would otherwise obstruct the view of your TextBox should just start working again.
*EDIT
A simpler solution might be to make sure your settings panel popup is parented in your visual tree - e.g. by adding it as a child element to a root grid of your app or page. It turns out that in that case its content does get pushed up when the OSK shows up.
Take a look at this post
It's a popup wrapper (turns user controls into popups) that takes care of the keyboard appearing and adjusts the size of the popup (and thus the user control) accordingly.

UI Design on Windows Mobile/CE

I have recently started on a project developing a window mobile/ce buisiness application. I have a ui design that uses a wizard to capture input data. To get the wizard started we open a windows form and maximize it. The form has one panel on it that is set to the size of the form. We pass a reference to the panel into the wizard controller as a container for the wizard user controls (each wizard step is a user control and the user control's size is set to that of the panel and thus the windows form. When viewed in a windows mobile emulator this works great the user control takes up the entire screen and the controls on the wizard step control are all visible on the screen with no vertical or horizontal scroll bars visible. When we load this onto one of the potential handheld devices the windows form doesn't fit exactly onto the screen as I would expect. There are both horizontal and vertical scroll bars and the controls aren't all visible. Does anyone have any hints and tips on getting around this problem? Is it possible to maximize a windows form in such a way that it exactly fills the screen on any mobile or ce device?
You need to check the screen resolution of your emulator and of your handheld device.
I suspect you are working on different screen resolutions.
If it's the case, then set the screen res for your emulator to match the screen res of your device. If for some reason this is not possible, just create your form to match the screen res of the device and try to fit all your UI in that limited space.
If you need to support many screen resolutions, you have 2 approaches:
1. Develop for the lowest res. This might look a bit ugly for higher res devices
2. Use anchors and control docking when defining your form layout.

Is there an easy way to recreate the WinForms layout experience at runtime for user positioning of controls

When laying out a WinForm in Visual Studio you get the ability to resize and align your controls very easily with drag handles and border alignment hints.
I'd like to do the same with a runtime control to enable the user to position an image on a page.
For example, if the user has a photo and they want to place it as a background on the desktop I'd like the control to help them move and size the photo thumbnail in a mini desktop visual.
I can do all of this, but my real question is, does anyone know of a way to inherit from the standard WinForms layout editor so that I can choose to use the nice docking, alignment hints and control resizing without coding it all again?
Thanks in advance
Ryan
I don't know about easy, but you can host the actual winforms designer in your own applications without too many problems.. See here.

Resources