Dynamic/Adaptive Gridview to have itemtemplates stretch using RelativePanel in Win10 XAML - c#

I would like to reproduce the News app in Win10 and have my ItemTemplate resize/stretch depending the size on my Window and also be able to move around depending on the size of the windows (so that this can work for Phone and Tablet apps).
I have tried using RelativePanel with a Listview but my items are not resizing, should I be trying to use a Gridview and work with VariableSizedGridView?
Does it look like this application is using 2 Gridview that are stack one on another with 2 different visual states depending on the size of the window?
Here are screenshot of the app and a video of the smooth effect that i would like to reproduce:
http://www.dailymotion.com/video/k47ZXBmcfBWnd0dbp9M
Edit:
It looks like they used an ItemTemplateSelector to have a different style on the first two elements. but I am having issues getting my elements to stretch.
Screenshots:

Related

Items clipping off-screen for some users in WinForms application

I am experiencing a very strange issue, and unfortunately it is not very reproducible so I don't have a lot to go on.
I have a page in a WinForms application laid out as per the below. Previously it was just a TableLayoutPanel anchored to the top, bottom, left and right, but now it is a Panel Docked into Fill mode with the same anchored TableLayoutPanel inside:
On all computers I have been able to try it on (including with and without Windows' Zoom functions), it displays like the above. However a small number of users experience a screen that looks like the below, with items clipped off screen (this user doesn't have access to the first tab, so it is hidden):
Items are clipped off screen and because of the anchoring, resizing doesn't help, they just expand.
I'm unsure how this is triggered but I think it could be something to do with the zoom of the machine being used for Visual Studio vs the zoom of the machine running the application; with that said I've tried running the application on various different zoom levels and can't reproduce the problem on my end. I have also tried adding a panel docked to Fill the area but that doesn't seem to have done much.
Is this something anyone has seen before with WinForms or can provide any suggestions?
Based on the comment from #rene, I looked at the answers on Creating a DPI-Aware Application - the two parts of the answer that resolved it for me were:
Disable any scaling on the machine(s) being used for development
Run a bulk string-replace across the application's code-base for this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; nand replace it with this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;, and develop all future forms with the AutoScaleMode set to None

Floating controls in dynamic width container in XAML

I am new to XAML and is trying to at runtime add a dynamic number of buttons to a container which scales with the current window width and height.
The buttons should be centered and placed beside each other and if there are not enough space on one line, the button which is too wide is moved above the other buttons and so on, resulting in a "floating" behavior as known from HTML.
If there are enough buttons to scale the containers height larger than the window it should be possible to scroll in the container, this part i dont think is a problem but the "float" behavior i cannot figure out how to do.
I have tried with the available panels but none seem to suit this purpose and i am thinking about creating a custom control which positions child controls in the way i want, but there must be some way this can be achived using standard controls?
I am developing this in UWP as an universal app for both desktop and mobile.
Thanks for any input to my problem :)
Maybe you could achieve what you want with a combination of a RelativePanel and a couple of VisualStates and visual state triggers such as AdaptiveTrigger or some from the WindowsStateTriggers library. With these you could define different visual states, each representing a different layout of buttons and define triggers that apply these states based on some conditions (most likely based on the size of your container). There's a very good example of this approach described in this blog post.

Show grid lines not appearing

I'm trying to make my grid show its gridlines in WPF. In Silverlight, I believe there was a property called grid.showgridlines, but that doesn't exist in Windows Phone 8 WPF. Is there any alternative?
I'd really like to clean up my xaml from having rectangle objects being duplicated a million times over.
Thanks!
I'm assuming that you are writing a Windows Phone app, not a WPF program. That said, the remarks for the Grid.ShowGridLines property in WPF are informative:
Enabling grid lines creates dotted lines around all the elements within a Grid. Only dotted lines are available because this property is intended as a design tool to debug layout problems and is not intended for use in production quality code. If you want lines inside a Grid, style the elements within the Grid to have borders.
(emphasis mine)
In other words, even in WPF it wasn't intended that you use this property in your production code. The advice to style the elements within the Grid control to have borders should work as well in the other XAML APIs (Windows Phone, WinRT).

Control positions in Runtime not consistent with designer

Let me explain put it in just a few simplest lines.
I made a new C#/WPF application project in VS 2013 ultimate (x64).
On MainWindow I insert (for example) a button at bottom-right, actually anywhere..
See image below, but the position of the buttons at runtime does not match what it looks like when I am designing
As you can see from the marked up spots in the 2 images, the controls are mispositioned.
I tried to change some XAML attributes, setting min/max sizes, and so on and on. I am running a fresh-install Windows 7 Ultimate (x64) OS, with "Windows 7" aero theme.
I played around MainWindow/Grid properties (tried almost every one), also when I loaded up some custom theme (for example: Expression Dark) issue persists.
Don't get excited so much. Have some control on your temper.
It seems that you have not set the Right Margin of the button you have circled Red in the above image. Try to set the appropriate margins from the Property Window of the corresponding button and see what happens!

C# Web Form button size change when running from different OS

I can not figure out why my web form buttons change size when I run the web form from Windows 7 vs. Windows Server 2003. I have set the positioning and size on page load for all objects. Here is an example of a couple of the objects I am using.
Label1.Style.Add("Position", "fixed");
Label1.Style.Add("TOP", "20px");
Label1.Style.Add("Left", "50px");
btnQuery.Style.Add("Position", "fixed");
btnQuery.Style.Add("TOP", "370px");
btnQuery.Style.Add("Left", "198px");
The buttons have the same 3 entries. When I run this from my local Windows 7 PC, everything looks great. However, when I publish this to my Server 2003 site, the buttons are about 5 times longer and cover each other up. My label, textbox, and listbox are all fine as well. It is just the buttons. Is it because I am developing on Windows 7? Also, I am doing this in Visual Studio 2010, Framework 4.
They are changing because you are giving the size in pixels. If users have different screen resolutions, then it will change how large the buttons are in relation to the screen. Use relative sizing to fix this. This is not OS dependent, may just seem like it.
You're only setting the top/left position of the button, but not the size... If not specified, then web browsers are free to make buttons look however they want.
Assuming that this Style.Add method actually translates to CSS, try adding:
btnQuery.Style.Add("height", "120px");
btnQuery.Style.Add("width", "300px");
Then tweak those so its the size you want.
Generally, I'd advise against using fixed positioning at all, but that is a different story.

Categories