2
votes

I have xaml custom listbox item, which height is 165px

I'm fillin StackPanel with those items:

StackPanel list = new StackPanel();
foreach (Course course in Semestris.Courses)
{
    TI.Course.Text = course.Name;
    list.Children.Add(TI);
}
Color color = ConvertStringToColor("#FF838383");
Brush brush = new SolidColorBrush(color);
list.Background = brush;
list.Height = list.Children.Count*165; //make size of stack panel just as to display all elements

And add color to find a bug.

This stack panel is being placed inside Expander StackPanel:

Expander.Expander a = new Expander.Expander();
a.IsExpanded = false;
a.Content = list;
a.HeaderContent = Semestris.Name;

Expander control has every row set to auto which means it will aply sizes of children.

And the last step to place all Expander into 1 stack:

Stack.Children.Add(a);

And my problem is that:

All colapsed expanders work fine:

Collapsed

When items are not many, all works fine:

1 item

But when items count is over 30 items it does this:

Cutted off

Where is the problem?

2
Why the fixed height value and no mvvm?Chris W.
Chris, fixed height of the list box element is needed because then the elements look better =) What is MWM?Cheese
msdn.microsoft.com/en-us/library/windowsphone/develop/… - I ask because I'm not really used to seeing so much manipulation of UI elements via code behind instead of xaml.Chris W.

2 Answers

1
votes

Looks like you have an issue with the height property somewhere in your stackpanel or expander (regardless of how many items you have in your list or expander). But just like Chris W. I would like to suggest to put all UI related statements more in XAML then in the code behind.

When you do so, use more Grids with rowdefinitions set to auto or * as height to indicate a necessary or all remaining height and use binding for data. Might be some rework, but from there it is more easy to see what is really happening...

0
votes

The best thing was to develop my own Expander.