Scroll behaviour when you have an ItemsControl within an ItemsControl
Posted: 04 Jul 2024, 15:37
Greetings,
I have a bit of a curious issue which I can't seem to resolve myself. I have an ItemsControl which loads a collection of items. Let's call it Parent. The items are organized in a StackPanel with Vertical Orientation and each item consists of a TextBlock (title) and another ItemsControl which loads another collection of items. These items are interactive and are organized with a WrapPanel. Essentially, I'm using the Parent to render a list of groups and each group renders its own collection of items.
My expectation is that I'd be able to scroll vertically, but I'm encountering some issues. The Parent's vertical scrollbar triggers, but it works only if I click and drag the actual scrollbar. It doesn't respond to the mouse wheel which I presume is because the MousePreview is stolen by the child ItemsControl. I'm also unable to scroll items by moving focus with keyboard/gamepad. If the focus moves to an item that is outside of the bounds the content doesn't scroll.
Is there a workaround for this? I've attached a wireframe of my setup.
Note: I'm not using fixed height as I'd like my layout to adapt to the window size.
I have a bit of a curious issue which I can't seem to resolve myself. I have an ItemsControl which loads a collection of items. Let's call it Parent. The items are organized in a StackPanel with Vertical Orientation and each item consists of a TextBlock (title) and another ItemsControl which loads another collection of items. These items are interactive and are organized with a WrapPanel. Essentially, I'm using the Parent to render a list of groups and each group renders its own collection of items.
My expectation is that I'd be able to scroll vertically, but I'm encountering some issues. The Parent's vertical scrollbar triggers, but it works only if I click and drag the actual scrollbar. It doesn't respond to the mouse wheel which I presume is because the MousePreview is stolen by the child ItemsControl. I'm also unable to scroll items by moving focus with keyboard/gamepad. If the focus moves to an item that is outside of the bounds the content doesn't scroll.
Is there a workaround for this? I've attached a wireframe of my setup.
Note: I'm not using fixed height as I'd like my layout to adapt to the window size.