stackpanel

How to loop through WPF StackPanel static Items?

旧城冷巷雨未停 提交于 2019-12-23 08:07:12
问题 Probably very easy but I am having trouble to figure this out (also Google doesn't seem to help much). How can I loop through the statically declared elements (no databinding - elements are declared in the xaml) of a StackPanel? Any help appreciated! 回答1: Do you mean the StackPanel 's children? foreach (var child in stackPanel.Children) { //do something with child } A more generic solution that would work regardless of the parent would be to use LogicalTreeHelper or VisualTreeHelper ,

Making a StackPanel scrollable in Windows Phone 8

孤者浪人 提交于 2019-12-22 18:27:28
问题 I have a list of controls, put into a stackpanel. These controls are Hubtiles, that are added programatically after a user creates it - a list essentially. I need to make the StackPanel in which they are added, scrollable - what would be the best approach for this? Should i put the stackpanel inside a ScrollView, and then increase the StackPanels height with the actual height of the Hubtile - to make it scrollable, but not so that the user can scroll infinite without something being there. So

Making a StackPanel scrollable in Windows Phone 8

﹥>﹥吖頭↗ 提交于 2019-12-22 18:27:05
问题 I have a list of controls, put into a stackpanel. These controls are Hubtiles, that are added programatically after a user creates it - a list essentially. I need to make the StackPanel in which they are added, scrollable - what would be the best approach for this? Should i put the stackpanel inside a ScrollView, and then increase the StackPanels height with the actual height of the Hubtile - to make it scrollable, but not so that the user can scroll infinite without something being there. So

Silverlight: Canvas overflows

不羁岁月 提交于 2019-12-21 09:34:30
问题 I have created a Canvas, and within it I placed a StackPanel. The StackPanel is horizontal, and it accepts a list of thumbnailed images. The Canvas has a fixed size. When I put more thumbnails than the Canvas width can hold, the StackPanel is supposed to overflow from the Canvas, so I can move it to center the current thumbnail. Everything works correctly, only, the StackPanel's overflow is visible! Is there a way to hide it? Or is the entire approach wrong? Here is a screenshot. The canvas

How to make items in a DockPanel expand to fit all available space in WPF?

点点圈 提交于 2019-12-21 07:56:18
问题 I have a StackPanel containing a StackPanel and some other items. The first StackPanel has a vertical orientation, the the inner one has a horizontal orientation. The inner one has a TreeView and a ListView , I would like them to expand and fit the width of the window, which I set by the window and allow the user to change. I would also like the outer StackPanel to fit the height of the window. How do I do this? Edit: I've converted to using a DockPanel , and I've set the DockPanel.Dock

WPF - setting HorizontalAlignment= Stretch to Textbox in StackPanel

旧巷老猫 提交于 2019-12-21 07:16:41
问题 Why doesn't a textbox stretch to fill space in a stackpanel? Is this by design? In a grid, the textbox stretches as expected. 回答1: Yes, it's by design. The StackPanel will allocate the space the TextBox asks for. If you haven't set a width on the TextBox , it will require only enough width to fit its text. 回答2: Kent's answer seems right. To still force override the StackPanel behavior, I think you'd need to dynamically compute-set the Width property of the contained elements OR some funky

WPF - setting HorizontalAlignment= Stretch to Textbox in StackPanel

元气小坏坏 提交于 2019-12-21 07:16:35
问题 Why doesn't a textbox stretch to fill space in a stackpanel? Is this by design? In a grid, the textbox stretches as expected. 回答1: Yes, it's by design. The StackPanel will allocate the space the TextBox asks for. If you haven't set a width on the TextBox , it will require only enough width to fit its text. 回答2: Kent's answer seems right. To still force override the StackPanel behavior, I think you'd need to dynamically compute-set the Width property of the contained elements OR some funky

How to get the position of an element in a StackPanel?

冷暖自知 提交于 2019-12-18 12:32:46
问题 Say I have a StackPanel that gets dynamically filled with copy, changing the Y position of elements inside it. I have a specific element within that StackPanel that I want to find the Y position of (relative to the StackPanel or otherwise) after the StackPanel is done repositioning all of it's children. StackPanel sp = new StackPanel(); sp.Children.Add(someTextBlock); sp.Children.Add(element1); sp.Children.Add(element2); ... someTextBlock.Text = "Lorem ipsum dolor..." // some text that pushes

sorting elements in a stackpanel WPF

两盒软妹~` 提交于 2019-12-18 06:08:06
问题 I have a stackpanel with some usercontrols that are added or removed during runtime. These elements have an index that i assign to them when i new them, I need to keep these elements sorted by that index so i wote a quicksort function that sorts them based on the index but on the line that does the swapping y = items[i]; //y is a temp variable items[i] = items[j]; I get "Specified index is already in use. Disconnect the Visual child at the specified index first" I tried copying them to a temp

Horizontal scroll for stackpanel doesn't work

那年仲夏 提交于 2019-12-17 05:14:46
问题 I try to create a scrollable horizontal StackPanel but I do not succeed very well... Currently I have my StackPanel with an auto width (and the problem is maybe here) that contains some items like grids . Now, if all my grids are not visibles in the StackPanel (width is too short) I can't scroll. I already tried to put the StackPanel within a ScrollViewer but it doesn' t work too. How can I fix this? EDIT here is my code: <StackPanel Height="85" Margin="0,0,200,15" VerticalAlignment="Bottom">