У меня есть Индикатор активности , и у меня нет проблем с тем, как он выглядит или что-то подобное, я просто не могу отобразить его при нажатии кнопки.
Есть Длительный процесс , что мне нужно go бросил при проверке товаров на корзине.
Структура метода :
Button Clicked => Api Calls
=> await IsinStock()
=> Fetch Products
=> await SingleCheck() || await VariableCheck()
=> No Errors => AddOrder || Errors Display Error
My Для индикаторов устанавливается значение Активен до вызова API и Завершается после завершения проверки и возвращается, чтобы добавить или показать ошибки.
Но он просто не отображается.
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:o="clr-namespace:Octane.Xamarin.Forms.VideoPlayer;assembly=Octane.Xamarin.Forms.VideoPlayer"
xmlns:local="clr-namespace:Ecombeta"
xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
x:Class="Ecombeta.Views.Cart">
<ContentPage.Content>
<AbsoluteLayout>
<Grid
RowSpacing="0"
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!--My Beautiful Ui Mark up here-->
</Grid>
<!--Loading Indicator-->
<AbsoluteLayout IsVisible="{Binding running}" AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1">
<BoxView
BackgroundColor="#80000000"
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1" />
<StackLayout
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1">
<Frame Padding="20,15"
CornerRadius="7"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
BackgroundColor="Black"
HasShadow="false">
<StackLayout VerticalOptions="Center"
HorizontalOptions="Center">
<ActivityIndicator
IsRunning="{Binding running}"
HorizontalOptions="Center"
VerticalOptions="Center"
Color="White" />
<Label Text="{Binding LoadingIndicatorMessage}"
x:Name="lblLoadingText"
HorizontalOptions="Center"
VerticalOptions="Center"
TextColor="White" />
</StackLayout>
</Frame>
</StackLayout>
</AbsoluteLayout>
<StackLayout Padding="5" AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All" BackgroundColor="White">
<ListView x:Name="cartView"
HasUnevenRows="True"
SeparatorColor="Black"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
SeparatorVisibility="Default"
IsPullToRefreshEnabled="True"
ItemSelected="EvetClicked">
<ListView.Resources>
<ResourceDictionary>
<local:BgConverter x:Key="BgConverter" />
</ResourceDictionary>
</ListView.Resources>
<ListView.Header>
<Label Text="Shopping List" HorizontalOptions="Center" VerticalOptions="Center"
HorizontalTextAlignment="Center" Margin="0,0,0,15" TextColor="Black"
FontAttributes="Bold" FontSize="Title" />
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Vertical">
<Label TextColor="Black" x:Name="something" HorizontalOptions="CenterAndExpand"
Text="{Binding ProductName}" FontSize="Subtitle" />
<ffimageloading:CachedImage
HeightRequest="150"
WidthRequest="150"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
DownsampleToViewSize="true"
Source="{Binding ImgSource}" />
<Label IsVisible="{Binding _virtual}" HorizontalTextAlignment="Center"
TextColor="Black">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding CartAtribKey }" FontAttributes="Bold" />
<Span Text="{Binding CartAtribValue , StringFormat=' {0}' }"
FontSize="Small" />
</FormattedString>
</Label.FormattedText>
</Label>
<Label IsVisible="{Binding _virtual}" HorizontalTextAlignment="Center"
TextColor="Black">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding CartAtribKey1 }" FontAttributes="Bold" />
<Span Text="{ Binding CartAtribValue1, StringFormat=' {0}'}"
FontSize="Small" />
</FormattedString>
</Label.FormattedText>
</Label>
<!--<Label HorizontalOptions="EndAndExpand" VerticalOptions="StartAndExpand" Text="{Binding PId, StringFormat='SKU {0:F0}'}" FontSize="Medium"></Label> -->
<Label FontSize="Large" VerticalOptions="CenterAndExpand" TextColor="Black"
HorizontalOptions="CenterAndExpand"
Text="{Binding TotalDynamicPrice, StringFormat='Total R:{0,5:#,0.00}' }"
FontAttributes="Bold" />
<Label HorizontalOptions="CenterAndExpand" TextColor="Black"
FontAttributes="Bold"
Text="{Binding Source={x:Reference stepper}, Path=Value, StringFormat='Quantity {0:F0}'}"
FontSize="Medium" />
<StackLayout Orientation="Horizontal">
<ImageButton HorizontalOptions="Center" VerticalOptions="Center"
HeightRequest="30" WidthRequest="30"
Source="https://mm-app.co.za/wp-content/uploads/2020/01/icons8-remove-64.png"
BindingContext="{Binding PId}" Clicked="Removevalue_Clicked" />
<Stepper x:Name="stepper" Maximum="{Binding StockQuantity}"
Value="{Binding ProductQuantity}"
Minimum="{Binding MinQ}"
ClassId="{Binding PId}"
TabIndex="{Binding VariationId}"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
Increment="{Binding IncrementQ}"
ValueChanged="stepper_ValueChanged" />
</StackLayout>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout Padding="0" Orientation="Horizontal" BackgroundColor="White">
<Button Margin="2" TextColor="white" BorderColor="#0088d3" BackgroundColor="#0088d3"
CornerRadius="10" Padding="10" VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" Text="Buy Now!" Clicked="ImageButton_Clicked" />
</StackLayout>
</StackLayout>
</AbsoluteLayout>
</ContentPage.Content>
</ContentPage>
private async void ImageButton_Clicked(object sender, EventArgs e)
{
running = true;
try
{
//You cant checkout if your not logged in There are no Guest Checkouts(I can But would rather not)
if (Users.LoggedIn && _spamClick == false)
{
if (_orderlineitems == null)
_orderlineitems = new List<OrderLineItem>();
RestAPI rest = new RestAPI("http://xxxx/wp-json/wc/v2/","xxxxxxxxx","cs_xxxxxxxxxxx");
var wc = new WCObject(rest);
await IsInStock();
}
running = false;
}
(...)
}
public partial class Cart : ContentPage, INotifyPropertyChanged
private bool _running;
public bool running
{
get => _running;
set
{
if (_running == value)
return;
_running = value;
RaisePropertyChanged();
}
}
Есть идеи?