I have listview and I insert list of data as itemsource for the list but the list item always not displaying and how I can refresh/update list data directly when new item added to list ?
this is my xaml :
<StackLayout Margin="0,0,230,0"
VerticalOptions="Start"
Grid.Column="0"
Grid.Row="0"
Orientation="Vertical">
<StackLayout BackgroundColor="{DynamicResource Gray-Bg}">
<Grid
ColumnDefinitions="*, Auto"
RowDefinitions="Auto, 1"
RowSpacing="0"
>
<!-- Table number -->
<Label
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="16,16,16,5"
HorizontalOptions="Start"
Style="{StaticResource TitleLabelStyle}"
Text="10" />
<!-- Order State -->
<Label
Grid.Row="0"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="16,16,16,5"
HorizontalOptions="End"
Style="{StaticResource TitleLabelStyle}"
Text="Active"
TextTransform="Uppercase"/>
</Grid>
<Grid
ColumnDefinitions="*, Auto"
RowDefinitions="Auto, 1, Auto, Auto, Auto, Auto, 1, Auto"
RowSpacing="0">
<buttons:SfButton
Grid.Column="0"
Grid.Row="0"
Grid.ColumnSpan="2"
Text="PICK UP"
HorizontalOptions="Start"
Margin="5,10,16,3"
TextColor="{StaticResource PrimaryColor}"
Style="{StaticResource TransparentButtonStyle}"
/>
<buttons:SfButton
Grid.Column="1"
Grid.Row="0"
Text="ADD CUSTOMERS"
HorizontalOptions="End"
Grid.ColumnSpan="2"
Margin="16,10,0,3"
TextColor="{StaticResource PrimaryColor}"
Style="{StaticResource TransparentButtonStyle}"
/>
</Grid>
</StackLayout>
<!-- Order listView -->
<StackLayout>
<Grid
BackgroundColor="{StaticResource PrimaryColor}"
ColumnDefinitions="*, Auto"
RowDefinitions="Auto, 1"
RowSpacing="1">
<Label
Grid.Row="0"
Margin="16,12,16,16"
HorizontalOptions="Start"
LineHeight="{OnPlatform Android=1.25,
Default=-1}"
Style="{StaticResource TitleLabelStyle}"
Text="Total"
FontSize="Medium"
TextColor="{StaticResource PrimaryText}"/>
<Label
Grid.Row="0"
Grid.Column="1"
Margin="16,12,16,16"
HorizontalOptions="EndAndExpand"
HorizontalTextAlignment="End"
LineHeight="OnPlatform Android=1.25,
Default=-1}"
Style="{StaticResource TitleLabelStyle}"
Text="{Binding TotalOrderPrice, StringFormat='{0} SR'}"
TextColor="{StaticResource PrimaryText}"
FontSize="Medium"/>
</Grid>
</StackLayout>
</StackLayout>
and this is my code:
private static ObservableCollection<Order> myList;
public static ObservableCollection<Order> MyList
{
get { return myList; }
set { myList = value; }
}
public CartPage(Order orderlist)
{
this.InitializeComponent();
MyList.Add(new Order()
{
OrderId = orderlist.OrderId,
OrderName = orderlist.OrderName,
OrderQuantity = orderlist.OrderQuantity,
OrderSize = orderlist.OrderSize,
OrderState = orderlist.OrderState,
OrderTotalPrice = orderlist.OrderTotalPrice,
OrderUnitPrice = orderlist.OrderUnitPrice,
OptionList = orderlist.OptionList
});
//Mylist have 3 items inside it
OrdersItemslist.ItemsSource = MyList;
OrdersItemslist.IsVisible = true;
// OrdersItemslist.RefreshView();
}
below here is the itemsource = MyList and contain data
|
|
here is my order class :
and I take the orderlist data from this popuo using this code :
when click button the data will sent to CartPage class :
in the CartPage there are 2 constructor 1- default and the second constructor will Fills the data in the list and this is the code :
and this is my xaml for listview :
this is the popup screen and take the data from it:
finally the list will be shown in left white space after click add to cart button :
the xamarin form version is 5.0.0.2012
the syncfusion version is 19.2.0.44
It still does not appear and I have attached pictures of the code and screens. Is there a suggestion for help?
|
private void SfButton_Clicked(object sender, EventArgs e)
{
Random r = new Random();
var 0 = new Order();
...
CartPage cartPage = new CartPage(o);
//Add the new page to the MainPage instance.
App.Current.MainPage = cartPage;
//CloseAllPopup
this.IsOpen = false;
} |
I do the same what u say but here is the result :