Hi,
I created the Listview using Xamarin.Forms. I could get the data in exploreList (Observable collection) and assign to ItemSource. So I can bind the value to Cell controls like Label using SetBinding. But some case I need to get the string data instead of Binding. Because I created the **Rating star** view in separate Layout class and included as one of children in Listview grid. So I need to pass the string Parameter. Please someone help me. Thanks in advance.
exploreListView = new ListView
{
RowHeight=100,
ItemsSource = exploreList,
ItemTemplate = new DataTemplate(() =>
{
Grid gridShop = new Grid {
Padding=5,
BackgroundColor=Color.Gray,
VerticalOptions = LayoutOptions.Fill, RowSpacing=7,
RowDefinitions =
{
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto }
},
ColumnDefinitions =
{
new ColumnDefinition { Width = new GridLength(70, GridUnitType.Absolute) },
new ColumnDefinition { Width = GridLength.Auto },
}
};
Image shopImage = new Image
{
WidthRequest=70, HeightRequest=70,
//Source = ImageSource.FromFile("NoPhoto_PH.png"),
VerticalOptions = LayoutOptions.CenterAndExpand,
Aspect = Aspect.AspectFill
};
Label statuslabel = new Label
{
//Text ="Now Opening",
Font = Font.SystemFontOfSize(NamedSize.Small),
VerticalOptions = LayoutOptions.CenterAndExpand,
};
Label Shoplabel = new Label
{
//Text ="Virgin Mega Store",
Font = Font.SystemFontOfSize(NamedSize.Medium),
VerticalOptions = LayoutOptions.StartAndExpand,
};
** RatingStar ratingStar = new RatingStar (“4”); // Need to pass the value**
//string logoUrl = Constants.b2oImageServer + "/images/shops/"+shopId+"/logo/"+logoUrl;
shopImage.SetBinding(Image.SourceProperty, new Binding("logoPath"));
statuslabel.SetBinding(Label.TextProperty, new Binding("openStatus"));
Shoplabel.SetBinding(Label.TextProperty, new Binding("shopNameEn"));
gridShop.Children.Add(shopImage,0,1,0,2);
gridShop.Children.Add(statuslabel,1,0);
gridShop.Children.Add(Shoplabel,1,1);
gridShop.Children.Add(ratingStar,1,2);
//======== make view Cell =========
return new ViewCell()
{
View = gridShop
};
})
};