MarekHolly
Topic Author
Posts: 7
Joined: 21 Mar 2025, 07:58

ListBox / Stack Panel sorting and item ordering.

02 May 2025, 14:03

Hi there.
I have ListBox, with Stack panel inside.
2025-05-02_13h56_51.png
2025-05-02_13h56_51.png (168.58 KiB) Viewed 11234 times
Content is driven by data set. Now there is 14 items, but there can be easily 50 + items in future, as game progresses. But my UI is designed to show just 10. Currently stack panel always starts with first entry at the top. But I need it to end with last entry at the bottom by default. So, as I said, I have 14 items right now, I would like to have item number 14 at the bottom, then 13 above and so on. Is it doable?

Thanks

Marek
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: ListBox / Stack Panel sorting and item ordering.

05 May 2025, 18:48

Just to make sure we understand the question... do you want to scroll the ListBox to the end when it gets loaded?
 
MarekHolly
Topic Author
Posts: 7
Joined: 21 Mar 2025, 07:58

Re: ListBox / Stack Panel sorting and item ordering.

09 May 2025, 07:44

Yes, exactly.
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: ListBox / Stack Panel sorting and item ordering.

12 May 2025, 10:54

For this you'll need an interactivity action that you can attach to the ListBox ScrollViewer (the one defined in ListBox's template), so when it gets loaded, it will scroll to the end of the list:
<ScrollViewer ...>
  <b:Interaction.Triggers>
    <b:EventTrigger EventName="Loaded">
      <local:ScrollToEndAction/>
    </b:EventTrigger EventName="Loaded">
  </b:Interaction.Triggers>
  ...
</ScrollViewer>
public class ScrollToEndAction: public TriggerAction<ScrollViewer>
{
  protected override void Invoke(object parameter)
  {
    ScrollViewer sv = AssociatedObject;
    if (sv != null) sv.ScrollToEnd();
  }
}
 
beshbalik
Posts: 1
Joined: 25 Mar 2025, 12:05

Re: ListBox / Stack Panel sorting and item ordering.

13 May 2025, 15:11

Could you please explain in more detail where exactly I should use this code?
public class ScrollToEndAction: public TriggerAction<ScrollViewer>
{
  protected override void Invoke(object parameter)
  {
    ScrollViewer sv = AssociatedObject;
    if (sv != null) sv.ScrollToEnd();
  }
}
How do I correctly use Noesis Studio together with C#?
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: ListBox / Stack Panel sorting and item ordering.

21 May 2025, 10:09

In case your project is built in Unity, you can create that interactivity action in C#. If it is a C++ project, then you have to write an equivalent code in C++.

The action should be added to the ScrollViewer contained in the ListBox template.

As Studio is not yet integrated into the Unity plugin or included in the SDK, your custom classes won't be visible in Studio, so you'll have to manually add for now this piece to your xaml:
<ScrollViewer ...>
  <b:Interaction.Triggers>
    <b:EventTrigger EventName="Loaded">
      <local:ScrollToEndAction/>
    </b:EventTrigger EventName="Loaded">
  </b:Interaction.Triggers>
  ...
</ScrollViewer>

Who is online

Users browsing this forum: No registered users and 1 guest