I have a Grid with two rows which are aligned at the bottom of my window.
By default the top row is always visible and the bottom is hidden. What I would like is when the mouse is over the grid, for the bottom row to display with animation rising up from the bottom.
Could someone help me with this.
Put the buttons in a panel, say a StackPanel, and place the StackPanel in the bottom row.
Then add a RenderTransform to the panel and animate the transform.
Related
I want to scroll a grid horizontally. By default, it scrolls pixel by pixel. I want to scroll column by column. Simply, a column should shift to left/right 100% or 0%. Shouldn't scroll by a fraction of it's width. (This applies to the first column visible to the user at the moment).
What I want is a way to do "snappy" scroll.
How can I get this done?
To scroll grid's content, use the GridView.LeftCoord property. To access boundaries of columns, the GridViewInfo.ColumnsInfo collection will be helpful. You can see how to implement this feature in the How to implement scrolling by columns in the grid e2481 example.
In the WinForm I am working on, I have two TextBox widgets and one button between the text boxes. When the form starts, and the winform is at its minimum size, the TextBoxes look as expected. No gaps between the items where they come close to the button there in the center. This is as seen in the top graphic.
However, when the user maximizes the winform, the TextBoxes move to the correct position but do not expand to keep close to the button in the center. Textbox A is anchored to the left and Textbox B is anchored to the right. So the alignment is correct. This is as seen in the bottom graphic.
Now, the question is how to make text box A grow to the right so that it comes close to the button in the middle and text box B grow to the left so that it also comes close to the button?
Thanks! Eric
Use TablelayoutPanel control. From MSDN
Create TableLayoutPanel with one row and three columns
First column: SizeType: percent, 50%
Second column: SizeType: absolute, 75(button width)
Third column: SizeType: percent, 50%
Then put textboxes and button in the columns.
Set for textboxes and button property .Dock = Fill
Size of the textboxes will be automatically changed with size of the columns in the TableLayoutPanel
Set Dock property of the TableLayouPanel to Fill or Bottom or Top. Then TableLayoutPanel will change width when width of the form is changed.
With simple anchors you cannot achieve this.
But you can use a TableLayoutPanel:
Place a TableLayoutPanel on the form and set Dock to Fill (or Top/Bottom)
Make 3 columns.
Column 1: Percent, 50%
Column 2: Absolute, set the desired size of the Button (eg. 100px)
Column 3: Percent, 50%
Drop TextBoxA into Column1, and set Anchor Left and Right
Drop the Button into Column2, and clear the Anchors
Drop TextBoxB into Column3, and set Anchor Left and Right
Without a TableLayoutPanel, you can make the following:
TextBoxA: Anchored Left and Right
Button and TextBoxB: Anchored Right
So only TextBoxA will grow.
you can use the Anchor Property for Button and textbox -
Button A - Anchor - left and Right
Button B - Anchor - left and Right
you can also, set textbox anchor property as per your needs and control the location of all these three controls.
I am trying to establish the following behavior: When hiding the bottom (blue) panel I want the top (red) panel to stretch to replace it vertically and vice versa (hiding red panel should expand blue).
Using a table layout panel with auto sized rows I was able to get the blue to stretch upwards but I can not get the red panel to grow downwards.
It's difficult to see from the far right picture but the bottom table row did not shrink with the panel. Table layout panel is not a requirement for me but I was hoping it would offer a solution.
Try using a SplitContainer control instead.
You can control each panel's visibility with the Collapsed properties:
splitContainer1.Panel1Collapsed = true;
or
splitContainer1.Panel2Collapsed = true;
I've a grid splitter before to the expander(which exists in the right side of a wpf window) and when i was running the app i need to use grid splitter to see more data from expander after its expanded, but the problem is when i was drag splitter i'm getting full view of my expander irrespective of original width but after click on expander to collapse it won't go to its original position by maintaining the splitter dragged width. So any one help me how can i send back expander to its original position.
Thanks,
#nagaraju.
Once you have used the splitter the grid column widths will no longer be 'auto'.
One solution is to respond to the collapsed event of the expander and reset the width of the first column to auto using column.Width=GridLength.Auto;
As you are resizing the contents of the Expander it may make more sense to place the GridSplitter inside the Expander, and on the outside you just have a normal Grid which makes the cell where the Expander is size to content.
I need to display a 1 pixel wide border around all wrap panel cells, kinda like excel grid. Unfortunately the wrap panel does not implement the grid ShowGridLines property. I can't put a border inside every cell because adjacent cells will have a 2 pixel border instead of 1 pixel.
Since the wrap panel arranges it's layout dynamically and does not expose it's properties I can't evaluate the correct value for a border inside a cell. Any workaround possible?
There is no way to show grid lines because it's just not a grid. Even in a WPF grid control, you have very little control over the appearance of lines: How can I change the color of the gridlines of a Grid in WPF?. They're really just for debugging. The workaround is to put a border inside each cell that only has thickness on the bottom and on the right: BorderThickness="0,0,1,1"