-
- MarekHolly
- Posts: 7
- Joined:
ListBox / Stack Panel sorting and item ordering.
Hi there.
I have ListBox, with Stack panel inside.
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
I have ListBox, with Stack panel inside.
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
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: ListBox / Stack Panel sorting and item ordering.
Just to make sure we understand the question... do you want to scroll the ListBox to the end when it gets loaded?
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: ListBox / Stack Panel sorting and item ordering.
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:
Code: Select all
<ScrollViewer ...>
<b:Interaction.Triggers>
<b:EventTrigger EventName="Loaded">
<local:ScrollToEndAction/>
</b:EventTrigger EventName="Loaded">
</b:Interaction.Triggers>
...
</ScrollViewer>Code: Select all
public class ScrollToEndAction: public TriggerAction<ScrollViewer>
{
protected override void Invoke(object parameter)
{
ScrollViewer sv = AssociatedObject;
if (sv != null) sv.ScrollToEnd();
}
}Re: ListBox / Stack Panel sorting and item ordering.
Could you please explain in more detail where exactly I should use this code?
How do I correctly use Noesis Studio together with C#?
Code: Select all
public class ScrollToEndAction: public TriggerAction<ScrollViewer>
{
protected override void Invoke(object parameter)
{
ScrollViewer sv = AssociatedObject;
if (sv != null) sv.ScrollToEnd();
}
}-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: ListBox / Stack Panel sorting and item ordering.
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:
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:
Code: Select all
<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