In my project, I need to show a list of buttons with choices in custommessagebox.
Now, I have no problem in setting it up, but when I create the longlistselector, add it to scrollviewer and show the cusstommessagebox, only a few buttons are shown and i can't scroll for more.
The code I have is following:
private void btnChronicity_ButtonClicked(object sender, Events.LinkEventArgs e)
{
editBox = new CustomMessageBox()
{
....
};
ScrollViewer viewer = new ScrollViewer();
choiceSelector = new Controls.MessageBocChoiceSelectorControl();
List<items> chronicity = new List<items>();
foreach (ChronicityModel chronicity in ...Chronicities)
{
chronicity.Add(new items(chronicity.Name, chronicity.Selected, chronicity.Id));
}
choiceSelector.ItemSource = chronicity;
editBox.Content = viewer;
editBox.Show();
}
and the choiceselector is usercontrol, which looks like:
<StackPanel>
<Controls:LongListSelector x:Name="LayoutRoot">
<Controls:LongListSelector.ItemTemplate>
<DataTemplate>
<Controls1:CheckableListButton Header1="{Binding Header}"
Selected="{Binding Selected}"
Link="{Binding Link}"
ButtonClicked="CheckableListButton_ButtonClicked"/>
</DataTemplate>
</Controls:LongListSelector.ItemTemplate>
</Controls:LongListSelector>
</StackPanel>
where listbutton
is another control, basically button
containing several textBlocks
, boolean indicating whether it is selected (another style) or not and a string Link
, which is returned in custom click event.
The result looks this way:
But the problem is I can't scroll...
Why is it behaving like that? How to fix it?
EDIT:
As I play with the longlistselector and stuff around I have found out that the scrolling works, the problem is the LongListSelector only loads as much items as fits the messagebox instead all of them..... (when i create smaller messagebox, it shows less items, when i create bigger, it shows more)
So the question shifted a bit to:
HOW TO MAKE LONGLISTSELECTOR SHOW ALL OF THE ITEMS INSTEAD OF JUST AS MUCH AS FITS THE SCREEN.
This is how I used longlistselector in my code and it works perfectly for me with infinite scrolling. See if it helps you.