开发者

Floating ListBox Elements in Silverlight

开发者 https://www.devze.com 2023-03-15 04:08 出处:网络
Is there a way to mimic the CSS float: left; behavior for ListBox elements? I have a situation where I need to display a dynamic number of buttons on a page and they all need to sit next to each othe

Is there a way to mimic the CSS float: left; behavior for ListBox elements?

I have a situation where I need to display a dynamic number of buttons on a page and they all need to sit next to each other. Something like this:

--------------------------------------------- 
| Button 1 | Button 2 | Button 3 | Button 4 |开发者_如何学运维
---------------------------------------------

Again, the number of available buttons will not be known until run-time, so I can't just set up a grid to do this for me.

Thanks!


If you're not using the SelectedItem Property in the ListBox, I would suggest using an ItemsControl and overriding the ItemsPanel to a StackPanel with an Orientation="Horizontal" like CamronBute mentioned.

    <ItemsControl>
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
    </ItemsControl>>


Try a StackPanel. It should allow resizing and do what you need

0

精彩评论

暂无评论...
验证码 换一张
取 消