简体   繁体   English

在Windows Phone(8 / 8.1)应用程序中是否有Wrap Panel的替代品

[英]Is there an alternative to Wrap Panel in windows phone (8/8.1) apps

I have a ListBox whose ItemsSource is bound to a collection of Objects. 我有一个ListBox,其ItemsSource绑定到一个对象的集合。 My button content is bound to MyObject property "Name". 我的按钮内容绑定到MyObject属性“Name”。 When displaying on the UI, i want to wrap my buttons in such away that when they reach the end of the app i start displaying them in another new line of buttons . 当在UI上显示时,我想要将我的按钮包裹起来,当它们到达应用程序的末尾时,我开始在另一个新的按钮行中显示它们。 Apparently i am only displaying the first few buttons and the rest is cut off. 显然我只显示前几个按钮,其余按钮被切断。 The Wrap Panel which i was counting on seems to have been phased out. 我指望的Wrap Panel似乎已被逐步淘汰。

My view (xaml): 我的观点(xaml):

<ListBox Grid.Row="1" ItemsSource="{Binding Objects}">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal"></StackPanel>
          </ItemsPanelTemplate>
        </ListBox.ItemsPanel>


        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <Button  Margin="2" Content="{Binding Name}" Width="200" />                     
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

My ViewModel: 我的ViewModel:

public ObservableCollection<MyObject> Objects { get; set; }
    public MainViewModel()
    {
        Objects = new ObservableCollection<MyObject>();
        Add();
    }

    private void Add()
    {
      for (int i = 0; i < 15; i++)
        {
          Objects.Add(new MyObject() { Name = i});
        }
     }


    public class MyObject
    {
        public int Name { get; set; }


    }

ANY IDEAS !! 有任何想法吗 !! THANKS 谢谢

You can use an ItemsWrapGrid for that scenario, used in a similar way: 您可以对该场景使用ItemsWrapGrid ,以类似的方式使用:

<ListView ...>
    <ListView.ItemsPanel>
          <ItemsPanelTemplate>
               <ItemsWrapGrid .../>
          </ItemsPanelTemplate>
    </ListView.ItemsPanel>
</ListView>

您可以使用工具包中的wrappanel http://go.microsoft.com/fwlink/p/?LinkId=267555

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM