Dynamic columns on WPF - wpf

Assume we have a DataGrid like this :
First column is constant. others are come from database. In columns we display name of football players for example and below them we display some statistics about them .
What control do you suggest to use ?
If you suggest DataGrid how do I create columns and rows and connect them to data source ?
Any code example would be appreciated.

The functionality you are looking for is typically called a pivot table or Matrix. See Dynamic data matrix WPF for an example of how to do so in WPF.
Edit: If you are not trying to pivot, but just rotate it 90 degrees, there is a rather good answer on how to do that, too: WPF horizontal DataGrid. Basically just use a couple of LayoutTransforms to rotate the whole thing, then another set to rotate the cells back to normal.

Related

How could I interactively create an invoice and preview it on WPF?

I'm creating a trial project wherein my window has two grids, left grid is sort of a table that has labels and textboxes each row and asks for a specific part of the invoice like item, name, address stuff like that and the right grid is to show a preview of the invoice that the left side is creating.
I thought about using a document viewer on the right side but I thought that anything I open there would be static and if I put values on the textboxes on the left grid, it wouldn't matter since I opened a standalone document to view on the right grid.
I thought about just creating a table out of the right grid and have the default values and populate the other ones when a user types something on the textbox and make it function as the preview but then I don't know how would I go about and printing it and also, it has about 45 rows which I couldn't fit in the grid without it being unreadable (because I had to cram 45 rows of data inside that small grid)
So is there a tool in the toolbox that could potentially create a interact-able grid? I tried the grid control but I can't seem to only make it show 4 columns because that's all I need, I don't want it to show E and the rest of the alphabet because I want it to resize accordingly with only 4 columns to make it more readable.
Oh and I also have devexpress installed so you guys could also recommend something I can use from there. Thank You.
I think this is the best solution since it does what I wanted it to do.
I created a scroll view and placed a grid inside it then set the length accordingly to show it in a reasonable size and let the scroll bar do its magic for me to see the rest of the grid without compromises of the content's size.

Curving chart diagram

My goal is to have a diagram which look like this
Each arrow should be a one dimensional chart, where point are displayed (colors and point size depends on some values)
I'm building my own chart system because I spent a few hours looking for one which allow to custom markers (size and colors, and maybe even shape) but I couldn't find one.
Actually the only one I found is dynamic data display 2.0 which is only proposed in Silverlight.
My biggest problem is the two curving chart I have to do at the top of the diagram.
I tried to use PathListBox control, but because it's a listBox, I couldn't display items at fixed X position (like using a chart).
I'm not asking for a full perfect solution, but can someone give me advices, or clues ?
How would you manage to do something like that ?
It should only be a XAML work here, because all the data are already ready in a ListCollectionView (i'm using MVVM).
Thank you !

Merging DataGrid Cells (Row Wise & Column Wise)

This question might have beebn asked earlier but i have not found ne solution....
How can i merge Two(or More) Cells in WPF DataGrid...
I have found no in built provision to do it, also i doint even know how to start
this link shows some light but still no luck...
What i wish to do is i need to Merge Two Cells of a Particula DataGridRow/DataGridColumn based on some value (It can be ne thing) Just like we Do in Excel (merging cells)
Have you considered doing cell templates for that cell in the row? If you want the same pattern repeated, that's an idea. You can use stack panels to align things as you need them.

Any 3rd party Table like controls for WPF?

I know about Grid. What I don't like about Grid is that I have to specifically index every single row and col. So afterwards, if I want to just move one row or col, I have to go update a ton of xaml.
I tried stackpanel and styles but then even this is a lot of redundant xaml and rearanging the screen still involves then removing/updating styles.
I really like how in an html table, I just start laying out my rows and cols on the fly. If I want to move a row, that's easy, I can just copy paste the xaml to the right spot, nothing else needs to get touched. A col, is a bit harder, but still can be done easily with cut/paste, just needs to be done to every row.
With grid, one may need to touch every single thing in it depending on what's moved.
And what would be really cool, is if one could declare the column width and row heights up above just like a grid. But then as need, provide override values in the actual row,col declaration down below that actually contains the gui elements.
Does anything like this exist?
I've seen implementation of a Grid that infers ColumnDefinitions from usage of attached properties. Its definately doable. You could create an attached property that signifies that this element is the last element of a row.
(See WrapBreakPanel in Pro Silverlight 4 in C# By Matthew MacDonald)
And what would be really cool, is if one could declare the column
width and row heights up above just like a grid. But then as need,
provide override values in the actual row,col declaration down below
that actually contains the gui elements.
Sounds like this could get confusing. What if multiple cells in a row override the height? You can pull this off already with Auto sizing a row and having elements take up more space as needed.

Multi-column silverlight repeater?

It's easy to repeat templated data, using List box, or StackPanel + ItemsControl, etc. However, I cant figure how to get multiple columns, ie, column alignment.
Example:
Name: John Doe
Street: 123 st
City: Seattle
State: WA
This link below shows the general layout I am trying to programmatically replicate (scroll near bottom):
http://karlshifflett.wordpress.com/2008/10/23/wpf-silverlight-lob-form-layout-searching-for-a-better-solution/
Obviously, the data (and label) can vary in size. Also obvious, I could force a fixed width repeating a horizontal stackpanel, but that is lame.
In ASP.NET, you just use a repeater, and get results by repeating a table row + columns. Since an HTML table respects/adjusts the column sizes for ALL rows, the data will simply line up. In silverlight, you... do what?
Note: a datagrid could do this... by why on earth would you want to use that for simple layout of a "form" like this example?
Is the entire pattern above repeating, meaning you have this block of options for each item? If so, why not just make your ItemTemplate a Grid with the left column fixed width? If not, can you elaborate more?

Resources