Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cwenger opened this issue Dec 31, 2023 · 1 comment
Open

Comments

@cwenger
Copy link

cwenger commented Dec 31, 2023

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?

@cwenger cwenger changed the title CheckedListBox does not allow vertical item layout with horizontal overflow CheckListBox does not allow vertical item layout with horizontal overflow Dec 31, 2023
@XceedBoucherS
Copy link
Collaborator

XceedBoucherS commented Jan 15, 2024

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:

<Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:CheckListBox}"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <ScrollViewer Padding="{TemplateBinding Padding}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> <StackPanel> <prim:SelectAllSelectorItem x:Name="PART_SelectAllSelectorItem" Content="{TemplateBinding SelectAllContent}" Visibility="{Binding IsSelectAllActive, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BoolToVisibilityConverter}}" /> <!--<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>--> <WrapPanel IsItemsHost="True" Orientation="Vertical" Height="{TemplateBinding Height}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> </StackPanel> </ScrollViewer> </Border> </ControlTemplate> </Setter.Value> </Setter>

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants