Add a child dynamically with an animation - c#

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.

Related

Hide Child Objects Together with the Parent

I've got a little problem. On a button press I need to open a panel with settings in animation. The thing is when I reduce width and height of a parent object (panel) it does not hide the child objects whatsoever. How can I make the parent object to influence the children's height and width when I change them in the parent?
If these objects are UI elements you can use add a Mask to the panel to hide any child objects that go outside of the area of the panel. As you can see below the square which is a child of the panel object does not render anything outside of the area of the panel.
If you want the UI elements to scale with the changing size of the panel then you should use anchors which will mean that the children of the panel will "anchor" themselves to the positions you set. Here's a short gif to illustrate how it works.
That's with the child image set to preserve it's aspect ratio, if you disable that setting then the box will stretch to perfectly fit the anchors.
If you want to scale your child objects with your parent canvas, you should set your render mode -> world space in your parent object.

Put an adorner layer behind child controls

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.

WPF TreeView With Two Seperate ItemsPanel for Branches and Leaves

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.

How to set focused node Devexpress TreeListControl

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.

C#/winforms layout: element with anchor right or bottom vanishes under parent container

sometimes when i want a winforms control to be docked also to the right or bottom of the parent container (usually a UserControl), it's borders are extended way beyond the parent's right or bottom border, so that a part of it is not visible anymore. even though the anchor is set to right.
this only happens when the application is run. as long as i am in the designer view everything looks fine.
all i do is set the "Anchor" property of the control to "Right" for example.
is there a way to avoid this?
in this screenshot you can see the groupbox "Transition" extends way over it's parents extends to the right.
http://www.deviantsart.com/upload/08ffe2f5e7f4d33044840e68e0619152.png
thanks!
Check your parent (UserControl) dock and anchor properties. It appears to me that they have not been set and the UserControl not the items in the UserControl are extending past the borders.
If you use Anchor then you cannot use Dock (and vice versa).
The Anchor and Dock properties are
mutually exclusive. Only one can be
set at a time, and the last one set
takes precedence.
I would check if your controls' parent is actually the control you think it is (it could be its parent :-) ).
Also check Margin property on the control and Padding property on the parent control.
Then check AutoSize property.
I'm not exactly sure what you are saying. Can you reword the sentence?
If you are saying that when you resize the parent window, you want the control to also resize, you are on the right track. You should change the anchor so that the control is anchored to left, top, right, and bottom.
If you want to dock to the right, at a constant height: anchor:=top,right
If you want to dock to the bottom right corner: anchor:=bottom,right
What parent container are you docking in? Is the control inside the parent? If not, then it can resize over the top of it (since its not actually a child).
Perhaps the anchoring is fine, but the problem is in the rendering. Have you tried calling Invalidate() in your container control?
I remember something similar happened to me a long time ago with a custom control. And I resolved it by forcing a repaint of the control.
You probably have to mess around with the z-order of the controls.

Categories