WPF Listbox Wrapping

后端 未结 2 2056
广开言路
广开言路 2021-02-13 18:33

I have a listbox in which I use a ListBox.ItemsPanel - WrapPanel.



        
相关标签:
2条回答
  • 2021-02-13 18:43

    I am trying to have the wrappanel have a behavior such that the items fill in to the right as the width is made wider and wrap as needed when the window is made narrower. I have played with it but the correct combination eludes me. Does anyone have a suggestion?

    The code you have is almost correct, just change the Orientation to Horizontal and it should work as you describe

    My next goal would be able to reorder/ sort the items and have the render update.

    You don't have to do anything special for that, it's the normal behavior of a ListBox. Just change the sort order (using ICollectionView.SortDescriptions), and the UI will reflect the changes

    0 讨论(0)
  • 2021-02-13 19:03
                    <ListBox Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                    <ListBoxItem Name="lbiTmp3_1"><CheckBox>
                            <TextBlock TextWrapping="Wrap">
                            lkjfd gmlkdsfmlk gmdsgf  kds lkjglfdjmlkg jfdsg dsgf lkhfdgs lkjds fg
                        </TextBlock></CheckBox>
                    </ListBoxItem>
                    <ListBoxItem Name="lbiTmp3_2">C0ucou</ListBoxItem>
                    <ListBoxItem Name="lbiTmp3_3">C0ucou</ListBoxItem>
                </ListBox>
    
    0 讨论(0)
提交回复
热议问题