当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Add Multiple ListBoxes to a PivotItem in Windows Phone 7

问题描述:

I am fairly new to windows phone programming & I am having some trouble while adding multiple ListBoxes to a single Pivot Item, first of all, here is the code where I need help:

 ListBox ListA = new ListBox();

ListBox ListB = new ListBox();

Grid G = new Grid();

PivotItem P = new PivotItem();

G.Children.Add(ListA);

G.Children.Add(ListB);

P.Content = G;

Both Lists contain "Images", which are successfully displayed on the screen (Vertically aligned Icons basically)

My problem:

The last List added is scrollable & the previous one freezes, I cannot do anything in XAML because my Grid/Pivot are created programmatically, also the images in the second List are "clickable" but they are not in the first, what am I doing wrong?

网友答案:

It seems to Me that the 2nd ListBox overlap the 1st. Try to declare two columns for the Grid G , and put each ListBox in corresponding column, for example :

ListBox ListA = new ListBox();
ListBox ListB = new ListBox();

Grid G = new Grid(); 
PivotItem P = new PivotItem(); 

//declare two columns with equal width (Width="*" for each)
G.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
G.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

G.Children.Add(ListA);
G.Children.Add(ListB);

//set ListA in column 0 and ListB in column 1
Grid.SetColumn(ListA, 0);
Grid.SetColumn(ListB, 1);

 P.Content = G;
分享给朋友:
您可能感兴趣的文章:
随机阅读: