Show grid lines not appearing - c#

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).

Related

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.

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

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:

WPF layout changes (Fill, Full, Snapped)

I am working on a Win8 app destined for the Windows Store. Hurdles I am trying to overcome is how to deal with the different ways an app can be displayed.
Currently, my main pages is a LayoutAwarePage so it has logic to handle different visual states. However, my question is more how to make my page render differently depending on its state.
I thought, initially, that you basically created a layout for each state that the application supports. But it seems like the VisualStateManager portion of the XAML is just an area where you make piecemeal modifications to the design (hide an element, change an alignment).
I am working with a grid that has many columns and rows to organize my controls and it looks great in fullscreen. However, this doesn't work at all in the snapped state, as most of my controls become hidden off screen. I could certainly add a ScrollViewer control, but this is basically a hack and a usability nightmare for a user.
Thanks for any insight!
It might be that your app doesn't lend itself to snapped view. You are allowed to simply display a message / image that states this. Alternatively, consider just showing the columns that are most important.
The standard MS way seems to be to replace horizontal oriented controls with vertical ones - maybe a listview or something would look better. You'll probably find your code easier to read if you have one control for snapped and another for full screen.
Not exactly related to your question, but Blend works very well with XAML to allow you to manipulate the grid or show the relevant control.
Here is a very good guide from Jerry Nixon.
http://blog.jerrynixon.com/2012/12/walkthrough-implementing-snapview-in.html

Reproduce the Microsoft Registry Editor "Edit Binary Value" Window in VS 2010 C# .NET Windows Forms

I am trying to reproduce a window from the Microsoft built-in Registry Editor. The window is the one which is opened when you select "Modify Binary Data..." from the context-menu when a value is clicked.
The goal is to make an identical(!) window in my .NET C# application using Windows Forms.
The problem is the textBox displayed in the window which contains the binary data. I have tried using a RichTextBox, but it isn't as simple as it seems to be especially when it comes to editing data and the behaviour of this textBox.
So I have 2 questions:
How to achieve an identical textBox in C# using Windows Forms? Maybe you know some other ways to reproduce this textBox?
I also need the font name used in this textBox, I couldn't find it :)
Thanks!
I can think of two ways you can approach this. The first is a DataGrid, painstakingly styled to have transparent grid lines and exact margins between columns, with filters to enforce hex digits only. All this, set alongside a richtextbox for the ASCII display, with your code synchronizing the selection between them.
Alternately, you can replace the DataGrid with a collection of TextBoxes, again styled for invisible borders, automatically adding new textboxes to the collection when the user adds more data.
All in all, it seems like an awful lot of work, especially in WinForms - WPF might make this a bit easier, especially the styling, but still a lot of work.
Regarding the name of that control - I tried using Spy++ to sniff it out, and it seems it's registered as a Window Class named "HEX", but I'm not sure that will really get you somewhere:
Here is an open source project containing a hex editor control for Winforms, looking at least very similar:
http://sourceforge.net/projects/hexbox/
I guess you can modify it accordingly to your requirements. But beware, the source code for the control is ~6000 lines of code (including more than a dozen utility classes). It inherits directly from "Control" and does all the text display using GDI+ (so no modified DataGrid or RichTextBox).

Does a WPF Grid perform better than Winform's Table Layout Panel

I am currently working on an application that uses a Table Layout Panel to display a row of data. Each row contains a certain number of textbox and checkbox.
The number of rows present is usually quite big, making the loading and navigation of the Table Layout Panel extremely slow.
After some research, I've found that the TLP is one of the slowest Winform UI controls and I'd like to implement a WPF Grid instead.
My question is two-fold:
1) Does a WPF Grid perform better than a Table Layout Panel when it comes to a large number of rows ?
2) Is it possible to include WPF controls in an application that uses exclusively winform controls ? (The application uses .NET 3.5)
Thanks for your time and have a great day.
For performance, you'll have to do your own comparison. There are so many factors that could affect it that a well-written WinForms could be faster than a poorly-written WPF or vice versa. Just do a little prototyping and see if its an obvious win for you.
As far as using a little WPF in a mostly WinForms application, yes that is supported and can work well. Just put your WPF content in a WPF UserControl and then add an ElementHost to your form and host the WPF control inside that. Here's a lot more information:
Windows Forms – WPF Interoperability FAQ
Do you have background worker or thread for loading element into Table Layout Panel, if you have the problem with freezing?

Categories