在Xamarin.Forms中,我有一个带有2个标签的列表视图和其中的另一个列表视图。 为Android和iOS构建。
这是特定的代码
listView.ItemTemplate = new DataTemplate(() => {
var grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
Label l = new Label() { };
l.SetBinding(Label.TextProperty, new Binding("TeachersName"));
grid.Children.Add(l);
Label l2 = new Label() { };
l2.SetBinding(Label.TextProperty, new Binding("TeachersEmail"));
grid.Children.Add(l2);
Grid.SetRow(l, 1);
Grid.SetRow(l2, 2);
SfListView embeddedView = new SfListView();
embeddedView.AutoFitMode = AutoFitMode.Height;
embeddedView.LayoutManager = new GridLayout();
//embeddedView.SelectionMode = Syncfusion.ListView.XForms.SelectionMode.None;
embeddedView.LayoutManager.SetBinding(GridLayout.SpanCountProperty, new Binding("NoOfCat"));
embeddedView.SetBinding(SfListView.ItemsSourceProperty, new Binding("CatInfoSet"));
embeddedView.ItemTemplate = new DataTemplate(() => {
var MainGrid = new Grid() { VerticalOptions = LayoutOptions.StartAndExpand};
Grid Holder = new Grid() {Padding = new Thickness(5) };
SfCircularProgressBar circularProgressBar = new SfCircularProgressBar() {Margin = new Thickness(5)};
circularProgressBar.SetBinding(ProgressBarBase.ProgressProperty, new Binding("Percent"));
Holder.Children.Add(circularProgressBar);
Label label = new Label() { HorizontalOptions = LayoutOptions.Center };
label.SetBinding(Label.TextProperty, new Binding("Description"));
MainGrid.Children.Add(Holder);
MainGrid.Children.Add(label);
return MainGrid;
});
grid.Children.Add(embeddedView);
Grid.SetRow(embeddedView, 0);
return grid;
});
我有一种感觉,就像导致问题的行定义,但似乎无法弄清楚。
更新: :如果我重新排列网格项目,将标签放置在进度条之前,则它们会显示...这真的很奇怪
答案 0 :(得分:1)
您将RowDefinitions
的高度全部设置为auto
,并且listView
在row 0
中,它将自动占用所有空间,并且标签不会出现。尝试将absolute height
赋予{0}这样的第0行,您会在100
下看到这些标签。
类似的东西:
listView