Visually linking items in a grid - wpf

Does anyone know how to draw a line between two items in a grid? I would normally use a canvas but it does not provide the layout I want.
The grid is the ItemsPanel of an ItemControl object.
Thanks,
Adam

You have to do following things, Suppose you have three columns in the grid and one item is in the first column and second item is in the third column and you have to draw line between them. and I am supposing that all the columns of the grid has same width.
Write style for the button which only contain the line.
now set the left margin and right margin of the line ( which will be the button and style of the button , you have created as I have mention above), to the half size of the columns width, and set the columnSpan of the line button to 3.
Hope that will help.

Related

WPF Grid Lines show across childrent element with span > 1

Are there any way to make grid to not show over grid children?
I mean, I want grid lines to be visible, but when a children has rowspan or columnspan over 1, I want it to hide the grid lines.
I tried setting the children (it's a label) opacity to 1 but it didn't work.
Any help will be welcome.
No there is not. From MSDN:
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.

WPF - overlay text on top of datagrid row

I have a WPF datagrid where certain rows will be disabled. In addition to disabling the cell contents, I'd like to present to the user some text that overlays the row with an explanation such as "Row disabled due to ...". Basically the same effect of having a label control with a lower z-order sitting directly in front of the datagrid row's cells.
If cell text spillover was possible (like in Excel), I could create a text column of 0 width with the message, then let the message runover through the neighboring cells. But to my knowledge this type of text spillover isn't possible in the datagrid.
If your rows have fixed height, you could add a another transparent datagrid on top of the other datagrid. The transparent datagrid would have one column which would show the disabled explanation. Simple but hacky solution.
The proper way would be to use adorners.

How to Resize Cells in WPF Grid

After constructing a Grid and adding Rows and Columns to it, how can modify the dimension of each Cell. I am not able to locate any property that would help me to achieve this.
As additional note, I am adding TextBlocks to each of the cell.
You can change the column width and row height within your ColumnDefinition and RowDefinition tags, or if you wish to have the cells in a less uniform arrangement you can set the ColumnSpan (might be ColSpan, it's been a while!) and RowSpan properties of each cell to create cells that span more than one row or column.
Do you want modify cells dimensions at runtime? If yes take a look at GridSplitter.

Wrap Panel Item separators

Is it possible to separate items in a wrap panel with a horizontal line and to have the line wrap with the items (i.e. line from top row last item to next row first item?
The line width should be able to be set at run time, and the line that wraps should have additional feature of arrow heads showing direction of flow.
You could try using an ItemsControl which has it's ItemsPanelTemplate drawn as a WrapPanel. Then you could add your lines/arrows to the ItemsPanel.ItemTemplate

Spreading controls to fill space as a dialog resizes

I have a dialog with column down the right side filled with buttons. The dialog is built with Windows Forms. I have a mockup at the following link:original dialog
(I would have included it but apparently i'm not allowed to use image tags)
I would like for the buttons in the right column to resize themselves to fill the remaining vertical space when the dialog resizes. It doesn't particularly matter to me whether or not buttons simply increase in size or whether the buttons remain the same size while the gaps between them increase. I'm simply want the buttons to go from the top to the bottom. (I have a mockup for this as well but apparenlty i can only include one link)
I've tried hosting the buttons in a FlowLayoutPanel but they do not increase as the dialog stretches, I only get whitespace at the bottom after I run out of buttons. I also tried a TableLayoutPanel and had the same result but I may have misused it. Does anyone have any ideas how I could accomplish this?
Thanks in advance,
Jeremy
To get you started. Use the TableLayoutPanel, set its Anchor property to top, bottom, left, and right. Set the rows and columns to percentages as needed. I suggest each control have it own cell. Note that each control in a "cell" can have its Dock and Anchor property set as needed.
You can do this with a TableLayoutPanel. Create a column for the buttons, with each button having it's own row / cell in the column. Set each row to be an even percentage for height (if there are 10 buttons, each row would be 10%), and dock the TableLayoutPanel to the right side of the screen. Then, put the buttons into their rows and set them to full docking. Then, when the dialog expands, the TableLayoutPanel will expand to fill the entire right side of the screen, each row will adjust proportionally, and each button would expand to fit the new row size.
You may have to adjust this a bit to fit your needs, especially in how it relates to the other content in the window.

Resources