Resizable views UWP - c#

How do I make it so that a desktop UWP app will resize based on resolution? Mainly I need it to work between a surface pro and a Surface Studio. I've researched around google and I haven't seen anything that goes into detail. I know of things like RelativePanel and VisualStateManagers, but I have not clue how to use them. Any guidance would be much appreciated.

Use Grids to Place your elements. Specify the row height and column width as fractions (0.2*,0.2*,0.6*) so that it adds upto 1 (not necessarily, but for convenience). Then your UI will scale automatically based on resolution. You don't even have to use relative layouts. Just place them within these Grids. If you want complex actions, go with VisualStateManagers.

After doing more searching I came across this. I think I understand it now.
https://channel9.msdn.com/Series/Windows-10-development-for-absolute-beginners/UWP-037-Utilizing-the-VisualStateManager-to-Create-Adaptive-Triggers

Related

Control Application Flow According to Screen Size

I am new to windows phone development. I have an issue regarding screen size variation and I successfully handle the UI according to resolution but problem is that I don't have any idea how to change the size of text for different resolutions, use different images for different resolution etc.
As in Android we have different asset folders. We just put our data in folders and it will use best option automatically according to the screen size . I did a lot of Googling but did not find a suitable solution for it. Any idea how I can achieve this?
You shouldn't pay attention to screen sizes at all, everything is scaled up automatically and applications look good on smaller and larger screens.
If you want to customize the design for your screen depending on the screen size, DPI or something else, take a look at the proposed solution here: http://developer.nokia.com/community/wiki/Advanced_Techniques_for_Big_UI.

How to let controls maintain position after Window size changes

I am creating a Windows Store app, using XAML and C#.
If for example I run my application on the Windows Simulator (tablet), the layout is perfect. When I run my application on my local machine, the layout does not at all look like what it looks on the simulator.
How do I design my application to fit both perfectly?
Should I have multiple designs, and with start up check screen resolution and choose the layout best suited for that resolution?
Basically, how do I make sure my app will always look its best, no matter on what screen size it my run out there in the real world?
I am currently making use of a Grid for the layout of the controls, 3 columns, and 3 rows, with the Width and Height set to "*". I understand that with larger screen sizes, the column width and row heights will increase, and the opposite for smaller screen sizes.
I am basically just looking for good design practices, as to always try best and avoid massive layout changes.
I attended a Microsoft seminar lastly for 2 days. I asked if ViewBox exist for Windows Store Apps. They said "I don't think so" :)
But it exist :D
I'm sure it will be easy with a ViewBox http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.viewbox
Put your design in a view box. That's all. We use it for silverlight.

Learning resources for the WPF/XAML Illiterate

Okay, I know this has been asked before, but the solutions to previously asked questions haven't helped me. I've never made an app in XAML/WPF before and I feel really stupid when I try to learn it, but with the release of Windows 8 release preview, it is looking like I have to learn it.
Are there any resources that you would recommend to somebody as stupid as myself?
Thank you all
Specifically, my main trouble is not knowing how to properly position/align things on a Window in XAML. I find it extremely difficult to understand. I'm used to Docking things, and so forth, but I don't see any dock options for XAML. I'm also used to absolute positioning - or positioning by relativity from the edge of the window/screen - but that way doesn't work in XAML from what I've tried.
Specifically, my main trouble is not knowing how to properly position/align things on a Window in XAML. I find it extremely difficult to understand. I'm used to Docking things, and so forth, but I don't see any dock options for XAML. I'm also used to absolute positioning - or positioning by relativity from the edge of the window/screen - but that way doesn't work in XAML from what I've tried.
The key to this is understanding how the Layout System works in Xaml.
Once you understand the difference in the overall approach to layout, then understanding the individual panels and alignment make most things approachable.
The main difference is that the container typically handles the layout of the children. Instead of docking or aligning an element, you typically have the parent handle the layout, and use attached properties (ie: Grid.Row) to position the child within the parent.
This makes it far simpler to handle resolution independence, though it takes a bit of getting used to at first.
You can make use of Grid, Canvas, StackPanel, or WrapPanel (among others) to help position things.
It's usually a combination of the above controls, but the most common method I've seen is using the Grid to create rows and columns, and positioning your controls inside them.
I would recommend Josh Smith's tutorial http://www.codeproject.com/Articles/18251/A-Guided-Tour-of-WPF-Part-2-Layout
For an in-depth learning resource, check out the Pro WPF in C# 2010 book: http://www.amazon.com/Pro-WPF-2010-Presentation-Foundation/dp/1430272058/ref=sr_1_1?ie=UTF8&qid=1339377007&sr=8-1
It includes several chapters on elements and how positioning works. I've found it to be extremely helpful and would recommend it.
If you're not interested in reading something so lengthy, I would recommend viewing the example code on MSDN for different layout controls, such as the Grid, StackPanel, and DockPanel.

Render Tube and resize, dynamically add text

What I am looking to do in my Windows Forms application (or even WPF). Is to dynamically render an image of a tube, or cylinder (with a 3d look or having some sort of depth for a better visual experience), setting the length and hieght and so on, (also need rulers and such to zoom in and out). But then allow the user to enter some text, which will then be placed on that tube or cylinder, for display purposes, able to scale the text size, to create a visual representation of what it would look like IRL.
Any ideas on where I can start, or some examples I can build off of? This vector type display is new to me, so any help would be appreciated.
This article looked interesting. I would imagine you could tweak it to do what you were after.
http://kindohm.com/technical/WPF3DTutorial.htm
Also I googled "WPF 3D drawing".
If you have the choice WPF is better suited for graphics than WinForms out of the box. Though a good programmer can make WinForms do similar.

Set Screen.WorkingArea.Width?

Sorry if this is a fundamental question and I'm just stupid :)
I am building a sidebar application, it uses System.Windows.Forms.Screen.PrimaryScreen.WorkingArea to set the appropriate widths and heights and locations.
I want to now reduce the working area of the desktop so that when forms maximise, the sidebar is still shown (in the same way that the Vista or Google sidebars do)... but trying to set the Width on the WorkingArea.Width property gives me an error about the WorkingArea (a System.Drawing.Rectangle) not being a property.
What can I do to change the width of the WorkingArea to prevent forms overlapping my sidebar?
Thanks in advance!
Actually looking at this in more detail, it looks like it is much more involved and requires Win32 API calls to get the job done and get the exact same behavior.
This link contains some sample code on how to get it done. (Sorry, its ExpertsExchange, so scroll down, but it is a full sample.)

Categories