I'm wondering when modelling a real-world scenario such as a shelf stacking if it's possible to have different height items in a list box.
Assume the list box is meant to represent a shelf which is which has a height in inches or cm. I can stack boxes on this shelf up to the maximum height. I can have more smaller boxes and obviously less larger boxes. I know the dimensions of these boxes as well in inches or cm.
I'd imagine that I'll need to maintain a running total of all the items in the list box so as to know just how much shelf space I have left. I need to be able to visually show that one box is larger than the other by spanning n number of items.
Is the list box even the right control to consider using in this instance?
Yes, its the right control. Yes you can have different heights of items in a ListBox. Use DataTemplates to define the style of each container which ListBox will use to represent items. Each item will become a container with its individual height and style.
Take a look at those link:
http://www.wpf-tutorial.com/listview-control/listview-data-binding-item-template/
http://wpftutorial.net/ListBoxDataTemplate.html
Related
I have a list in my app that I'm creating with Sencha-Touch 2.3. Imagine a single list item that has multiple pieces of data equally spaced apart horizontally. There can be many list items like this. The size in between the boxes that are in each list item change depending on the device, because their size is a percentage of the devices width. What I described here is what I want to happen.
Right now I'm using an itemTpl with span elements. I gave the span elements a class so that I can reference it in css. The css changes I make to width do not make any difference to these span elements in each list item. The span elements all touch, with no space in between them no matter what I do.
How can I make what I described here happen? I've been searching the internet for an answer for a long time but haven't found anything.
Have you tried looking at the Ext.dataview.DataView with useComponents:true?
You can define a DataItem with a layout of hbox and use multiple sub-components with flex:1 to get a bunch of horizontal boxes with all equal width.
check out the docs here to get a sense of how to implement a DataItem inside of a DataView
I have a Box with a BindConstraint binding it to the width of the stage. I'd like to add actors and have them be evenly distributed across the width of the box. That is, I'd like the width of the actors to remain fixed, but the spacing between them to be such that the entire width of the box is filled.
At the moment I'm using a BoxLayout, but haven't found any combination of properties which achieves this effect.
It looks like setting "homogeneous" to true and packing with "x-align" as CLUTTER_BOX_ALIGNMENT_CENTER creates this effect.
Normally a WPF WrapPanel (Orientation="Vertical") will stack items vertically (and grow vertically) until it runs out of space from the parent container, and then it will "wrap" to the next column.
I want this functionality, but I want to add a hard limit to the number of items in a column. For instance, if my height is 100 and I have 3 items that are 30 pixels high, normally it could fit them all without wrapping. However, say I want to force it to wrap after 2. In that case, I want it to only grow to a height of 60, and wrap the 3rd item into the second column.
Is there something I can do to make this happen?
Maybe you can do it with the UniformGrid.
Use the Rows property to definie the amount of elements in vertical direction.
here is a nice little article about the available layout panels in WPF. If one of these does not fit the bill, you might have to build your own custom panel, here is a decent demo.
I have a control that has a list that varies in length greatly. This control appears in various places meaning that i cannot calculate its position and desired height easily.
Moreover all I want is for the scrollviewer to simply size itself according to its parent. currently it insists on sizing itself according to the content.
currently when i have a list that exceeds the height of the screen the whole control extends off the bottom and the scrollviewer shows no bar (because it has stretched to the heigth of the contents and so thinks it is not required).
I've not included code as the object graph is fairly deep.
What i am looking for is a set of conditions that would cause the scrollviewer to resize itself according to its content rather than its parent.
I have it working in a similar situation involving grids and datagrids, the unique part of this control is that there is a list containing controls.
Any ideas? I would prefer solutions that don't require use of code behind - but im really not in a position to be choosey.
Here are common reasons that come to mind that would allow a scroll viewer to size to its contents rather than to its "parent":-
It's placed on a Canvas or a StackPanel
It's assigned to a Grid row/column with it's Horizontal or Vertical alignment not set to Stretch and its content size is less than the size of the row or column.
Its ultimately upto the containing panel how it chooses to size a child element so its not really possible to dictate this completely from code inside the child.
well what i want is this lets say i have a "panel" with the width 100 and height 100
now i want to place X objects witht the size 20 so when i add more 5 items it should have all items on one line
|Item1|Item2|Item3|Item4|Item5|
now if i would add one more then i want it to split it to 2 lines with 3 items on each row
|Item1|Item2|Item3|
|Item4|Item5|Item6|
and well i guess you get the point, iv tryed stack panel but i cant get it to work the way i want it to..
Edit:
well it doesnt matter that mutch if each row has an equal amount of items.. so a wrapPanel should do the job next problem -> Here
There's no standard WPF panel that will do this for you. The WrapPanel comes close, but it will not make sure that your rows are even. Your best bet is to implement your own panel. Here's a good example on codeproject
The WrapPanel should suit your needs:
Controls are positioned in either a
stack or row based on the Orientation
property. In addition to stacking, the
WrapPanel provides wrapping support
for contained controls. Thus if more
controls are added to a WrapPanel than
can be displayed by the width of the
WrapPanel, they are wrapped around to
form an additional stack or row.
To be honest, I haven't tried that specific requirement myself.
I guess you could use WrapPanel... but then you would get 2 lines, (5 items and 1 item)..
What would happen if you had, say.. 7 items?
I don't think you will be able to get a container control that does that automatically. You could have a Grid with two rows and a StackPanel in each row. As you add the items you would need to programmatically select which StackPanel to put each item into.