xceedsoftware / wpftoolkit

All the controls missing in WPF. Over 1 million downloads.
Other
3.9k stars 878 forks source link

CheckListBox does not allow vertical item layout with horizontal overflow #1763

Open cwenger opened 10 months ago

cwenger commented 10 months ago

I would like a CheckListBox that stacks items vertically until the space is exhausted, and then continues at the top-right. For example, I can do the following with a plain ListBox in native WPF:

    <ListBox Height="50" Width="100" ScrollViewer.VerticalScrollBarVisibility="Disabled">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapPanel Orientation="Vertical" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBoxItem Content="A" />
        <ListBoxItem Content="B" />
        <ListBoxItem Content="C" />
    </ListBox>
image

When I try the same with a CheckListBox, it seems to ignore the disabling of the vertical scroll bar (the ItemsPanel seems to be followed because changing the WrapPanel orientation has an effect):

    <xceed:CheckListBox Height="50" Width="100" ScrollViewer.VerticalScrollBarVisibility="Disabled">
        <xceed:CheckListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapPanel Orientation="Vertical" />
            </ItemsPanelTemplate>
        </xceed:CheckListBox.ItemsPanel>
        <ListBoxItem Content="A" />
        <ListBoxItem Content="B" />
        <ListBoxItem Content="C" />
    </xceed:CheckListBox>
image

Is this a bug? Is there any way to achieve the desired item layout with a CheckListBox?

XceedBoucherS commented 10 months ago

Hi,

For now, there is no easy way since the CheckListBox's default ControlTemplate uses an ItemsPresenter. You best option would be to redefine the ControlTemplate to use a WrapPanel. Maybe something like:

`

` Thanks