Hello, Attached screen shot will help you understand the scenario, I have a welcome page having "Place Order" button and Order Page, on clicking Place Order button order page will be loaded by using given code:
Navigation.PushAsync(new Order());
I am populating ListView on Order form load by using given code:
public Order()
{
this.InitializeComponent();
GetSupplierItem();
orderDetails = new List<OrderDetail>();
NavigationPage.SetTitleView(this, new Image()
{
Source = "MatlobaMiqdar.png"
});
NavigationPage.SetHasBackButton(this, false);
}
public void GetSupplierItem()
{
Mainlistview.ItemsSource = Baqala.ServiceHandler.GetSupplierItemForOrderBySupplierID(1);
}
I want to show the loading animation till the listview loaded, to achieve this I have used ActivityIndicator but it does not worked, I tried a lot, here is my .xaml code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage.Content>
<StackLayout Padding="4" BackgroundColor="#f0f0f0" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<ActivityIndicator x:Name="activity" Color="YellowGreen" IsRunning="{Binding IsBusy}" IsVisible="{Binding IsBusy}" />
<ListView x:Name="Mainlistview" RowHeight="74" HasUnevenRows="True" SeparatorColor="YellowGreen" SelectionMode="None" ItemTapped="Mainlistview_ItemTapped" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" Margin="2,2,2,4" Spacing="1" >
<StackLayout Padding="2">
<Image x:Name="ItemPicture" Source="{Binding Item.ItemPicture, StringFormat='http://baqala-pk.com/Images/Vegetableimages/{0}'}" WidthRequest="70" HeightRequest="70" />
</StackLayout>
<StackLayout Orientation="Vertical" VerticalOptions="StartAndExpand" HorizontalOptions="StartAndExpand" Padding="0" Margin="4,0,0,0">
<Label x:Name="ItemName" Text="{Binding Item.ItemName}" TextColor="Orange" LineBreakMode="NoWrap" />
<Label x:Name="Price" Text="{Binding Price, StringFormat='RS.{0}/KG'}" HorizontalOptions="StartAndExpand" TextColor="#503026" FontFamily="calbiri" LineBreakMode="NoWrap" />
</StackLayout>
<StackLayout WidthRequest="130" Padding="0" HorizontalOptions="EndAndExpand" Margin="0,0,6,0">
<Grid HorizontalOptions="EndAndExpand" WidthRequest="120" HeightRequest="70" Padding="0,0,0,0" Margin="0,0,0,0" RowSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="22" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Frame Grid.Row="0" Grid.Column="0" CornerRadius="5" Padding="0" BackgroundColor="Gray" HorizontalOptions="End" WidthRequest="64" Margin="1">
<Label x:Name="ItemName2" Grid.Row="0" Grid.Column="0" Text="Rs.0" TextColor="White" FontSize="11" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" />
</Frame>
<Frame Grid.Row="1" Grid.Column="0" CornerRadius="6" Padding="0" BackgroundColor="LightGray" HorizontalOptions="End" WidthRequest="160">
<StackLayout WidthRequest="160" HeightRequest="22" Orientation="Horizontal" Padding="0" Margin="0" HorizontalOptions="End" >
<Button x:Name="DeductQty" Text="-" Clicked="OnClicked_DeductQty" CommandParameter="{Binding .}" Padding="0" Margin="0" BorderColor="YellowGreen" HorizontalOptions="End" HeightRequest="20" WidthRequest="24" IsEnabled="False" TextColor="White" Font="Bold, 20" />
<Entry x:Name="Qty2" WidthRequest="60" HeightRequest="14" Text="0" FontSize="Small" MaxLength="2" Margin="0" HorizontalOptions="Center" InputTransparent="True" TextColor="Black" ></Entry>
<Button x:Name="AddQty" Text="+" Clicked="OnClicked_AddQty" CommandParameter="{Binding .}" Padding="0" Margin="0" BorderColor="YellowGreen" HorizontalOptions="Start" HeightRequest="20" WidthRequest="24" BackgroundColor="YellowGreen" TextColor="White" Font="Bold, 20" />
</StackLayout>
</Frame>
</Grid>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Frame FlowDirection="MatchParent" CornerRadius="5" Margin="2" Padding="4" BackgroundColor="#d3d3d3" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" WidthRequest="400" >
<StackLayout Orientation="Vertical" HorizontalOptions="Center" VerticalOptions="Center">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Center" >
<Label x:Name="lblOrderTotal1" Font="Bold, 14" TextColor="Red" Text="Total: Rs." />
<Label x:Name="lblOrderTotal" Font="Bold, 14" TextColor="Red" Text="0.00" />
</StackLayout>
<Button x:Name="butPlaceOrder" Margin="0,2,0,0" Clicked="OnClicked_butPlaceOrder" HeightRequest="30" WidthRequest="160" FontSize="14" TextColor="White" BackgroundColor="Orange" Padding="0" CornerRadius="15" Text="Continue" IsVisible="False" />
</StackLayout>
</Frame>
</StackLayout>
</ContentPage.Content>