簡體   English   中英

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

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

我有一個ListBox,其ItemsSource綁定到一個對象的集合。 我的按鈕內容綁定到MyObject屬性“Name”。 當在UI上顯示時,我想要將我的按鈕包裹起來,當它們到達應用程序的末尾時,我開始在另一個新的按鈕行中顯示它們。 顯然我只顯示前幾個按鈕,其余按鈕被切斷。 我指望的Wrap Panel似乎已被逐步淘汰。

我的觀點(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>

我的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; }


    }

有任何想法嗎 !! 謝謝

您可以對該場景使用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