Is there an alternative to Wrap Panel in Windows applications (8 / 8.1)?

I have a ListBox whose ItemSource is bound to a collection of objects. The content of my button is bound to the MyObject Property Name. When you show in the UI, I want my buttons to be closed in such a way that when they reach the end of the application, and I start showing them in a new row of buttons. Apparently I only show the first few buttons and the rest are disabled. The Wrap panel that I was counting on has apparently been discontinued.

My view (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:

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 TO

+3


source to share


2 answers


You can use a wrapper from the toolkit http://go.microsoft.com/fwlink/p/?LinkId=267555



+2


source


You can use ItemsWrapGrid for this scenario, used in a similar way:



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

      

+6


source







All Articles