I have a Window with a WrapPanel containing a variable number of custom items.
By clicking on an item I need to display a panel containing some information about the item selected.
While displaying this panel I'd like the WrapPanel to fill all the available space like in the picture below.
The best I could come up with was to create a UserControl with a Grid with two row, each one containing a WrapPanel.
When the information panel is collapsed I would display only the first WrapPanel which will contains all the items.
While the information panel is visible, I would show both WrapPanels, moving some of the items from the first WrapPanel to the second.
Honestly though, I don't really like it and I was wondering if there was a better solution.
Related
I'm having a problem with a TreeView in WPF C#.
I have a TreeView with two TreeViewItems defined in XAML.
On the second TreeViewItem, I have a list of items defined by a binding.
When the list is too long, a vertical scrollbar appears and allows the entire TreeView to scroll.
But the two TreeViewItems must stay at the same place, so I'd like the content of the second to scroll instead, rather than the entire TreeView.
Left : what I get, and the two first items are scrolled out; Right what I'd like, with the two first items staying at the same spot. (The scrollbar is the red zone).
I look forward to hearing from you guys, and thanks in advance,
Raekh.
EDIT :
Found a solution : I removed the two treeviewitems and used a treeview with a item source obtained by binding, so the treeview starts after the treeviewitems and is scrolled properly.
Hello pplwould like to know if we can do a panel like this in WPF.
Where I sent a list item for the usercontrol, and after that the control showed items that were possible, and if more it shows the next and previous buttons. In windows forms I have. Now wpf in that complicated. I can not show items as monitor size user even knowing how many are being presented, he puts her items and then can not do paging. Can you help me?
Cumps
You could have a horizontal StackPanel in the grid and scroll the StackPanel with two buttons.
I am asking for a programming approach.
This is my problem:
I have a WPF window, with a ComboBox at the top.
When user select the item in combobox, depends on the selection, the Grid below it will show a corresponding element, for example: if use choose Display from combobox, then the element in Grid will change to a ListView; and when user choose Add from combobox, the element in Grid will change to a form(textboxes).
Should I create several Grid, collapse them, and show them only when user make selection? Or any other more brilliant ideas?
Thanks.
Put a UserControl in the cell, and set its Content according to the control selected in the ComboBox.
There can be two ways:
You add one panel containing the controls required for each of the items in the combobox. You can hide all of them and on SelectedIndexChanged, you can show the appropriate panel. This will need more memory, but the implementation is simpler.
The other way will be to have a single panel and render the controls in run time on SelectedIndexChanged. This will need less memory, but will be complex to implement. Also rendering on run time might need some additional time (so the throughput).
What you can do is place a Panel(Like Grid, DockPanel) below the combobox and based on it's selection, dynamically add/remove controls in the panel.
For ex: If the user selects Display, then, remove all the child elements of the Panel and add a GridView.If Add is selected, remove all child elements and add a TextBox.
After adding, attach an event handler in code behind to perform the action you would want to perform.
I have a number of items which I wish to be contained in either a ListBox or an ItemsControl. The size of the control is fixed, but the size of its contents are not. It is possible for this control to have 13 items inside, but if the user wishes, only one is displayed at a time, and takes up the entirety of the available space. Two items visible roughly splits the available space in two and so-on.
I don't "require" selection, but I do require a context menu.
If I use a ListBox, I get almost everything I want EXCEPT that if I select an item on the far right, it will be centered and the view "jumps". I don't want this. However, if I use an itemscontrol, when the size of the items contained changes ItemsControl just draws completely wrong proportions (sets width to aprox 120% of what it should be if just one item were displayed).
Which control should I use? And I do I 'fix' it to do what I want?
I have to develop a control having one datagrid. now datagridtextcolumn have to be binded with one property of collection created in viewmodel.
based on data i have do one thing...
if for a row no of lines is more than 3 in last column's cell then show a button having text "More" with last cell else with text "Less" and on click of "More" button it should display full text data...
now this layout can be shrined as well as stretched at runtime according to window's height and width using viewbox control or any other way...
so how to achieve this thing any idea???
Basically you want a custom textblock control that displays a max of 3 lines and shows a more button (if there are more than 3 lines of text)*.
The more button expands the textblock and I imagine stays around to collapse it again?
As it sounds like you only have one column (more like a list), rather than customise the datagrid create a usercontrol (with a grid, textblock and button) that does what you want and bind that inside a templated column instead.
You will need to expose the Text property as a dependency property for it to bind to. Most of the details of creating this type of usercontrol are on my answer to this: putting Button inside a TextBlock(or maybe something else) to make it work like the one on video?
Just add your size logic and change the layout to suit your needs.
*Note: Personally I would use the MinHeight property of the usercontrol to set when the "More" button is needed, then it will be more flexible, but that is just a suggestion.