This question is locked. New answers and comments are not allowed.
I have discovered that I am getting incorrect values from my RadLoopingList controls due to the controls' height property being incorrect.
My controls are inside a grid with a height of 140. This restricts my controls to the same height, and they will only show the number of items that will fit inside that height regardless of the datasource used.
I have found that I can manually set the height to allow all items in, but that seems to be a hacky trial-and-error solution. I want to be able to set my height dynamically depending on the data being used to populate the list (e.g. sometimes I want 26 items, sometimes 5, sometimes 15, etc.)
I have tried setting the height to be calculated by a formula like this:
That formula works well until ~15 items are needed, at which point all the items are not populated into the control. If I have too few items sometimes the first one gets repeated (e.g. 123451 instead of 12345).
When not enough items (or too many) are in the control the control reports the wrong result when the index is changed (e.g. selecting a 1 doesn't necessarily return the index value of 1). It's as if the incorrect height leads to the control mis-counting what it is currently showing, and the behavior only seems to occur if you scroll through all items and loop back around.
So I need to make my control height exactly correct based on the number of items and the spacing between them in a way that lets me change the number of items for different instances of my controls.
What do I need to do to achieve this? I assume I'm overthinking it and there is something very obvious I'm missing.
Here is the layout for one of my controls. It is intended to only show one scroller item and 1 both above and below while scrolling:
My controls are inside a grid with a height of 140. This restricts my controls to the same height, and they will only show the number of items that will fit inside that height regardless of the datasource used.
I have found that I can manually set the height to allow all items in, but that seems to be a hacky trial-and-error solution. I want to be able to set my height dynamically depending on the data being used to populate the list (e.g. sometimes I want 26 items, sometimes 5, sometimes 15, etc.)
I have tried setting the height to be calculated by a formula like this:
looper1.Height = (numberofitems) * (looper1.ItemHeight + looper1.ItemSpacing)
That formula works well until ~15 items are needed, at which point all the items are not populated into the control. If I have too few items sometimes the first one gets repeated (e.g. 123451 instead of 12345).
When not enough items (or too many) are in the control the control reports the wrong result when the index is changed (e.g. selecting a 1 doesn't necessarily return the index value of 1). It's as if the incorrect height leads to the control mis-counting what it is currently showing, and the behavior only seems to occur if you scroll through all items and loop back around.
So I need to make my control height exactly correct based on the number of items and the spacing between them in a way that lets me change the number of items for different instances of my controls.
What do I need to do to achieve this? I assume I'm overthinking it and there is something very obvious I'm missing.
Here is the layout for one of my controls. It is intended to only show one scroller item and 1 both above and below while scrolling:
<
Grid
x:Name
=
"LayoutRoot"
Height
=
"140"
Background
=
"#FFBABABA"
>
<
Grid
>
<
Controls:RadLoopingList
x:Name
=
"looper1"
ItemSpacing
=
"5"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Center"
IsCentered
=
"True"
Width
=
"60"
Height
=
"1740"
ItemHeight
=
"60"
ItemWidth
=
"60"
HorizontalContentAlignment
=
"Right"
FontSize
=
"24"
Margin
=
"30,00,376,00"
ItemTemplate
=
"{StaticResource LoopTemplate}"
IsExpanded
=
"False"
Foreground
=
"Black"
/>
<
Controls:RadLoopingList
x:Name
=
"looper2"
ItemSpacing
=
"5"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Center"
IsCentered
=
"True"
Width
=
"60"
Height
=
"1740"
ItemHeight
=
"60"
ItemWidth
=
"60"
HorizontalContentAlignment
=
"Right"
FontSize
=
"24"
Margin
=
"120,0,279,0"
ItemTemplate
=
"{StaticResource LoopTemplate}"
IsExpanded
=
"False"
Foreground
=
"Black"
BorderBrush
=
"#FFD82525"
/>
<
Controls:RadLoopingList
x:Name
=
"looper3"
ItemSpacing
=
"5"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Center"
IsCentered
=
"True"
Width
=
"60"
Height
=
"1740"
ItemHeight
=
"60"
ItemWidth
=
"60"
HorizontalContentAlignment
=
"Right"
FontSize
=
"24"
ItemTemplate
=
"{StaticResource LoopTemplate}"
IsExpanded
=
"False"
Margin
=
"210,0,0,0"
Foreground
=
"Black"
/>
<
Controls:RadLoopingList
x:Name
=
"looper4"
ItemSpacing
=
"5"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Center"
IsCentered
=
"True"
Width
=
"60"
Height
=
"1740"
ItemHeight
=
"60"
ItemWidth
=
"60"
HorizontalContentAlignment
=
"Right"
FontSize
=
"24"
Margin
=
"300,00,98,0"
ItemTemplate
=
"{StaticResource LoopTemplate}"
IsExpanded
=
"False"
Foreground
=
"Black"
/>
<
Controls:RadLoopingList
x:Name
=
"looper5"
ItemSpacing
=
"5"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Center"
IsCentered
=
"True"
Width
=
"60"
Height
=
"1740"
ItemHeight
=
"60"
ItemWidth
=
"60"
HorizontalContentAlignment
=
"Right"
FontSize
=
"24"
Margin
=
"390,00,10,00"
ItemTemplate
=
"{StaticResource LoopTemplate}"
IsExpanded
=
"False"
Foreground
=
"Black"
BorderBrush
=
"{StaticResource PhoneAccentBrush}"
/>
</
Grid
>
</
Grid
>