Wrap Panel Item separators - wpf

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

Related

WPF Stretch Middle Content in DockPanel or Stackpanel

How do I stretch the content in the middle section of a Stackpanel or Dockpanel. I know that a dockpanel will stretch the last item but I need to stretch the middle item. I know that I could use a grid with * for the middle section but I want to be able to set the left and/or right items as collapsed depending on my window size.
You should still use a DockPanel with LastChildFill setted.
Your DockPanel will stretch the last element you put in it, not the last one according to view.
So you can put the element you want to stretch in the last position and use DockPanel.Dock="Top/Bottom/Right/Left" on others one.

Silverlight zindex with dynamically added controls

I have grid with some textboxes and an image which goes out of grid boundaries and I add this grids dynamically in my code to another grid.
I want to have my image on top of all the rest of the grids. Unfortunately each grid I add to the root grid will hover over my previous grid image.
Could you please suggest anything?! I have tried with zindex and it did not work in my case.
What I am doing wrong?
ZIndex only works for the immediate children of a panel-derived container (Grid, Canvas, Stackpanel etc). Otherwise it is down to the order they exist in the visual tree (i.e. the last one gets displayed on top).
If you have nested objects you simply need to think about the order they are added. The simplest way to do this is have two top level grids/panels, the first contains everything else and the last containing just the dynamically added children.
This way whatever you put in the second grid will always be on top of all other items (in the first grid/container).

Is it possible to Trim Wrapped Text at the bottom of the container in WPF?

I would like to trim the contents of a TextBlock at the bottom of the container when it runs out of space. The image below shows what I am trying to achieve.
The left cell contains text that is being wrapped at the end of the line, but is being cropped on the final line. The right cell (which I edited by hand) shows the effect I want to achieve by trimming the text on the last line.
Is there an (easy) way to achieve this in WPF?
Did you try the TextTrimming property?

Silverlight MouseDragElementBehavior. How to rearrange items after drag and drop?

I have stack panel with custom controls in it. User can add or remove the items.
I have attached MouseDragElementBehavior to each item. So now user can move them within the stack panel.
However the items now are arranged on arbitrary manner. Is a mess really. They stay where the user left them.
What I need now is to make them to be stacked as the stack panel supposed to be... Nicely one by one...
So I need to simply let user change the order of items by using drag / drop operation but items has to be stacked precisely.
There is DragFinished event, but I dont really see how the Behavior moves items. I thought it is Margin it changes but margins stays 0... I dont know what to do next.
Appreciate little help.
MouseDragElementBehavior does its work using a Transform on the RenderTransform property of the attached element (i.e. the one the behavior is applied to) (the exact type of transform depends on the state of the RenderTransform property but it will either be a TranslateTransform or a MatrixTransform).
The transform is not reset when you finish dragging (nor would you want it to be because the element would snap back to its position in the StackPanel when you started dragging) and this is why the element stays where "the user left them".
To change the items position in the StackPanel in the way you are talking about you will have to use the DragFinished event. What you probably want to do is work out where in the StackPanel the element will end up (as a result of the drag, i.e. which element in the panel it will "push" down) then create an animation to animate the element from its current position (where the user released the drag) to that final position in the StackPanel and another animation to move the "pushed" element in to its new position in the StackPanel (VisualTreeHelper can probably help here (I think)). Once those animations are finished just set the new index within the StackPanel for each item and remove the RenderTransform translation.

Visually linking items in a grid

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.

Resources