I'd like to change the focused node in my TreeListControl via code. For the sake of simplicity, I have this example:
A grid has two columns, left we have a TreeListControl, and at right there is a Canvas.
The TreeListControl is populated with nodes corresponding to some shapes in the Canvas (such as the shapes name, etc.).
What I already have done, is to highlight the shape in the Canvas by selecting the corresponding node in the TreeListControl.
Now what I'd want to do is the other way around: to change the focused node in the TreeListControl by clicking on a shape in the canvas.
Thanks in advance
You should set the TreeListControl's FocusedRow property to the instance of business object. In this case, everything should work properly.
Related
I'm building a drag/drop application in winforms c#, i need to drag a usercontrol and drop it to a flowlayoutpanle.
everything works fine, except the drop location, the flowpanel sets the droped items side by side.
how can I set the droped item to the the exact cursor position?
I'll extend my comment to an answer.
The problem is not based on drag'n'drop. The problem is based on a semantic level. A flowlayoutpanel is used, to automatically arrange it's contents.
See MSDN FlowLayoutPanel Control Overview
The FlowLayoutPanel control arranges its contents in a horizontal or
vertical flow direction. You can wrap the control's contents from one
row to the next, or from one column to the next. Alternately, you can
clip instead of wrap its contents.
So the flowlayoutpanel-control does exactly what it's supposed to do. If you want to give the dropped control a specific location based on coordinates you want to use a normal panel. A normal panel will not arrange its contents automatically.
I have a canvas where I need to draw a grid, but behind child controls. I tried to create a new adroner and just add it to the canvas, but this adorner is displayed over child controls. How can I make this adorner be behind canvas' children? I don't want to draw this grid in the OnRender function of the canvas...
Clarification: grid is not a control. it is a painted grid or net on the canvas. it is created for making position elements easier.
One way to do this is to use a TileBrush as the Canvas.Background and set the TileBrush to an appropriate grid pattern.
An Adorner can only ever be on top (it allways has the highest zindex). You need to look at another solution to your underlying issue
Use the Panel.ZIndex Property to set the order elements get displayed on the z-plane.
I'm creating a graph with a TreeView. Below is a screen shot. So far everything is done with styling. I'm setting the TreeView's ItemsPanel to a horizontal StackPanel. (The paper clips are just place holders for items without an image.)
Notice the bottom level children are Leaves. They do not have any children themselves.
Here is the question: I want those items to go into a separate WrapPanel. The problem is an item can obviously have children with children and children without children (Branches and Leaves). The ItemsPanel still needs to be a StackPanel so you get a nice horizontal layout. But the last control in the StackPanel needs to be a WrapPanel with all of the childless children.
This is a screen shot I pieced together to show the Leaves in a WrapPanel.
Things I have tried
I've tried to create my own items panel converter, but that converts the entire items panel to a wrap panel.
I've tried to just add a separate tree view to the ItemTemplate and bind it to a separate collection, but that is not the correct look.
Something I haven't tried
The WrapPanel I'm talking about is almost like a branch. But the branch itself is empty, but contains children. Maybe I could change the style of the node based on a property. Then instead of showing a picture or whatever, it's data template would be a WrapPanel
I figured it out.
I looped through my hierarchical data set and made some changes. For each branch, I removed its leaves and added them to a new node. Then I add the node back to the branch. It sort of creates a place holder.
The node contains a property called "IsLeafCollection". It just verifies that each of its children do not have any children.
I have a data trigger that binds to IsLeafCollection. If it is true, then it changes the items panel to a wrap panel.
Below is a screen shot of the final outcome.
We could always add a child (or insert) to a root node dynamically. But how would be go about adding this child with an animation effect. For example adding a rectangle below an existing rectangle in a grid, I want it get added with a slide down effect.
Thanks guys...
Add the child to the root node in a collapsed state. Then, animate the transition from collapsed to expanded. It will seem (visually) that the addition of the child was itself animated.
I'm writing a 2D graphics tool in C# and WPF, and I'm using Adorners on the Shapes drawn to Canvas.
I'd like the adorners to highlight when a shape is considered "selected", which I'm currently doing using MouseDown and MouseUp events.
However, the user can select multiple shapes, so not all of the shapes will receive both of the mouse events.
I have a class that manages the drawing, which holds a List of the selected shapes. What is the best way to give the adorners access to this data, so they can see if their adorned element is selected?
Some thing's I've considered:
Making the List global - bad idea
Sub-classing each shape to add a "selected" property - would require changing all references to the shapes in my class
You can make an attached dependencyproperty you set on your shape - then you can set that property when you select one.
The adorner can have a visibility binding to the property on the shape so you get visibility set automatic.
You can also use the Tag property on the shape to store values - that is the old way of doing it :)