Skip to content

Selector.GetItemsHostOrientations reports Vertical for a horizontal ItemsStackPanel #25266

Closed

Description

@MartinZikmund

Current behavior 🐛

Selector.GetItemsHostOrientations() only recognizes StackPanel and IOrientedPanel. ItemsStackPanel does not implement IOrientedPanel, so when a ListView/ComboBox uses a horizontal ItemsStackPanel (Orientation="Horizontal"), the method still reports Vertical for both the physical and logical orientation.

// Selector.cs, GetItemsHostOrientations()
// TODO Uno: This implementation is simplified, should be ported from WinUI
if (panel is StackPanel sp) { ... }
else if (panel is IOrientedPanel orientedPanel) { ... }   // only VariableSizedWrapGrid implements it
// otherwise (Vertical, Vertical)

Expected behavior 🎯

Like WinUI, a horizontal ItemsStackPanel reports Horizontal/Horizontal. In WinUI ItemsStackPanel implements IOrientedPanel: get_LogicalOrientation returns Orientation and get_PhysicalOrientation forwards to it. ItemsWrapGrid does the same, with the physical orientation being the opposite of Orientation.

How to reproduce it (as minimally and precisely as possible) 🔬

GetItemsHostOrientations is protected virtual on the public Selector, so it can be observed from a subclass:

  1. Create a ListView subclass that exposes the method:
    public class ProbeListView : ListView
    {
        public (Orientation Physical, Orientation Logical) Probe() => GetItemsHostOrientations();
    }
  2. Put it in a loaded page:
    <local:ProbeListView x:Name="lv">
        <local:ProbeListView.ItemsPanel>
            <ItemsPanelTemplate>
                <ItemsStackPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </local:ProbeListView.ItemsPanel>
        <x:String>A</x:String>
        <x:String>B</x:String>
    </local:ProbeListView>
  3. After the control is loaded, call lv.Probe().
  4. Result: (Vertical, Vertical). Expected: (Horizontal, Horizontal).

Note: this was confirmed by reading the source on master (permalinks below), not by running the snippet above.

Impact

  • Selector.HandleNavigationKey computes isVertical from this method. Today the visible effect is small: ComboBox only reaches it for Home/End/PageUp/PageDown and the gamepad triggers, and NavigateByPage is still a TODO. The gamepad left/right trigger paging uses the wrong axis for a horizontal ItemsStackPanel.
  • Any further port of WinUI code that calls GetPanelOrientations / GetItemsHostOrientations (drag-over zones and keyboard reorder in ListViewBase) will get the wrong axis.
  • ItemsWrapGrid is not implemented in Uno, so only ItemsStackPanel is affected for now.

Workaround 🛠️

Switch on ItemsPanelRoot (ItemsStackPanel.Orientation) before falling back to GetItemsHostOrientations().

Works on UWP/WinUI

Yes. WinUI's Selector::GetPanelOrientations queries IOrientedPanel, which ItemsStackPanel and ItemsWrapGrid implement.

Affected platforms 📱💻🖥️

All (the code is shared, not platform-specific).

Uno.Sdk version (and other relevant versions) 📦

master @ cc48541

IDE version 🧑‍💻

N/A

Anything else we need to know? 💬

WinUI parity is backed by the WinUI C++ sources (dxaml/xcp/dxaml/lib/): Selector::GetItemsHostOrientations / Selector::GetPanelOrientations in Selector_Partial.cpp, ItemsStackPanel::get_LogicalOrientation / get_PhysicalOrientation in ItemsStackPanel_Partial.cpp, and the IOrientedPanel interface entry in ItemsStackPanel.g.cpp.

Uno side (master cc48541):

  • protected virtual (Orientation PhysicalOrientation, Orientation LogicalOrientation) GetItemsHostOrientations()
    {
    // TODO Uno: This implementation is simplified, should be ported from WinUI
    var panel = ItemsPanelRoot;
    var logicalOrientation = Orientation.Vertical;
    var physicalOrientation = Orientation.Vertical;
    if (panel is StackPanel sp)
    {
    logicalOrientation = sp.Orientation;
    physicalOrientation = logicalOrientation;
    }
    else if (panel is IOrientedPanel orientedPanel)
    {
    logicalOrientation = orientedPanel.LogicalOrientation;
    physicalOrientation = orientedPanel.PhysicalOrientation;
    }
    return (physicalOrientation, logicalOrientation);
  • internal void HandleNavigationKey(
    VirtualKey key,
    bool scrollViewport,
    ref int newFocusedIndex)
    {
    bool bInvertForRTL = false;
    bool isVertical = false;
    FlowDirection direction = FlowDirection.LeftToRight;
    Orientation physicalOrientation = Orientation.Vertical;
    int nCount = 0;
    var spItems = Items;
    nCount = spItems.Count;
    direction = FlowDirection;
    bInvertForRTL = (direction == FlowDirection.RightToLeft);
    (physicalOrientation, _ /*pLogicalOrientation*/) = GetItemsHostOrientations();
    isVertical = (physicalOrientation == Orientation.Vertical);
    switch (key)
    {
    case VirtualKey.Left:
  • internal override Orientation? PhysicalOrientation => Orientation;

Suggested fix: implement IOrientedPanel on ItemsStackPanel (both orientations return Orientation). ItemsStackPanel already has an internal PhysicalOrientation override on Panel that Selector does not use. Add a test that probes the method through a ListView subclass as above.

Activity

  1. added
    kind/bug
    good first issue
    triage/untriaged
    area/listview 📃
    project/items 🧾
    platform/all
    difficulty/starter 🚀
    area/combobox
    on Oct 11, 2026
  2. seragAhmed commented on Oct 31, 2026

    @seragAhmed
    Contributor

    Hi! I'd like to work on this one.

    Plan: make ItemsStackPanel implement IOrientedPanel like WinUI (LogicalOrientation returns Orientation, PhysicalOrientation forwards to it), so Selector.GetItemsHostOrientations() picks it up, and add tests for both orientations.

  3. added a commit that references this issue on Nov 5, 2026
    9ae963a
  4. added a commit that references this issue on Nov 20, 2026
    7f34693
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/comboboxarea/listview 📃difficulty/starter 🚀good first issuekind/bugplatform/allproject/items 🧾triage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions