[英]How to hide the "Navigate" button if the user presses the "Complete Delivery" in Xaml?
I am doing an app for the courier service.我正在为快递服务做一个应用程序。 I am trying to figure out how to hide the "Navigate" button when the user presses the "Complete delivery".
我想弄清楚如何在用户按下“完成交付”时隐藏“导航”按钮。 I tried some codes but no luck.
我尝试了一些代码但没有运气。 Thanks in adv!
谢谢你!
enter image description here在此处输入图像描述
// This is the XAML Code: // 这是 XAML 代码:
<ContentPage.Content>
<StackLayout>
<Grid Padding="10,10,4,0">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100*" />
<ColumnDefinition Width="10*" />
</Grid.ColumnDefinitions>
<DatePicker x:Name="dateselector" DateSelected="HandleDateSelected" Grid.Row="0" Grid.Column="0"></DatePicker>
<Picker HeightRequest="2" IsVisible="false" Title="ORDERS" x:Name="ordersfilterpicker" FontSize="Small" Grid.Row="1" Grid.Column="0">
<Picker.Items>
<x:String>MY DELIVERIES</x:String>
<x:String>FOR PICKUP</x:String>
<x:String>RELEASED BY WAREHOUSE</x:String>
<x:String>ONGOING</x:String>
<x:String>COMPLETED</x:String>
</Picker.Items>
</Picker>
<ImageButton Margin="-10,3,0,0" WidthRequest="32" VerticalOptions="Start" BorderColor="Transparent" BackgroundColor="Transparent" Padding="5,5,5,5" Clicked="HandleRefreshButton" Source="refresh.png" Grid.Row="0" Grid.Column="1" />
</Grid>
<ActivityIndicator IsRunning="False" IsVisible="False" IsEnabled="False" Color="CornflowerBlue" VerticalOptions="CenterAndExpand"
HorizontalOptions="FillAndExpand" HeightRequest="80" WidthRequest="80"
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1" x:Name="activityind"/>
<ListView Margin="5,20,5,20" ItemTapped="riderOrdersListView_ItemTapped" x:Name="riderOrdersListView" ItemsSource="{Binding aorderinfo}" VerticalOptions="FillAndExpand" HasUnevenRows="True" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid RowSpacing="5" Padding="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="70" />
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="55" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="10*" />
</Grid.ColumnDefinitions>
<BoxView HeightRequest="25" Color="LightGray" Opacity="0.4" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"/>
<Label Text="REFERENCE NO." Font="Bold,Small" TextColor="Black" Grid.Row="0" Grid.Column="0"/>
<Label Text="SALES ORDER" Font="Bold,Small" TextColor="Black" Grid.Row="0" Grid.Column="1"/>
<Label Text="{Binding checkoutcode}" Font="Bold,Medium" TextColor="#777777" Grid.Row="1" Grid.Column="0"/>
<Label Text="{Binding salesorderno}" Font="Bold,Medium" TextColor="#777777" Grid.Row="1" Grid.Column="1"/>
<BoxView HeightRequest="25" Color="LightGray" Opacity="0.4" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"/>
<Label Text="PICKUP ADDRESS" Font="Bold,Small" TextColor="Black" Grid.Row="2" Grid.Column="0"/>
<Label Text="DROPOFF ADDRESS" Font="Bold,Small" TextColor="Black" Grid.Row="2" Grid.Column="1"/>
<Label Text="{Binding address1}" VerticalOptions="Start" VerticalTextAlignment="Start" TextColor="#503026" Grid.Row="3" Grid.Column="0"/>
<Label Text="{Binding clientaddress}" VerticalOptions="Start" VerticalTextAlignment="Start" TextColor="#503026" Grid.Row="3" Grid.Column="1"/>
<BoxView HeightRequest="25" Color="LightGray" Opacity="0.4" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2"/>
<Label Text="EXPECTED DELIVERY" Font="Bold,Small" TextColor="Black" Grid.Row="4" Grid.ColumnSpan="2"/>
<Label Text="{Binding requested_deliverytime}" VerticalOptions="Start" VerticalTextAlignment="Start" TextColor="#503026" Grid.Row="5" Grid.Column="0"/>
<Label Text="{Binding status}" VerticalOptions="Start" VerticalTextAlignment="Start" TextColor="Red" Grid.Row="5" Grid.Column="1"/>
<BoxView HeightRequest="25" Color="LightGray" Opacity="0.4" Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2"/>
<Label Text="ORDER TOTAL" Font="Bold,Small" TextColor="Black" Grid.Row="6" Grid.Column="0"/>
<Label Text="REMARKS" Font="Bold,Small" TextColor="Black" Grid.Row="6" Grid.Column="1"/>
<Label Text="{Binding ordertotal,StringFormat='PHP {0:N}'}" VerticalOptions="Start" VerticalTextAlignment="Start" TextColor="#503026" Grid.Row="7" Grid.Column="0"/>
<Label Text="{Binding confirmremarks}" VerticalOptions="Start" VerticalTextAlignment="Start" TextColor="#503026" Grid.Row="7" Grid.Column="1"/>
<BoxView HeightRequest="25" Color="LightGray" Opacity="0.4" Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="2"/>
<Label Text="GRAND TOTAL" Font="Bold,Small" TextColor="#777777" Grid.Row="8" Grid.Column="0"/>
<Label Text="{Binding grandtotal,StringFormat='PHP {0:N}'}" VerticalOptions="Start" VerticalTextAlignment="Start" Font="Bold,Small" TextColor="#CCCCCC" Grid.Row="8" Grid.Column="1"/>
<Button BackgroundColor="CornflowerBlue" BorderRadius="5" Clicked="HandleNavigateButton" Text="NAVIGATE" TextColor="#503026" Grid.Row="8" Grid.Column="0"/>
<Button BackgroundColor="CornflowerBlue" BorderRadius="5" Clicked="HandleBookButtonAsync" Text="{Binding buttonlabel}" TextColor="#503026" Grid.Row="8" Grid.Column="1"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
//This is the Code for the buttton for the "Order Complete" //这是“订单完成”按钮的代码
async void HandleBookButtonAsync(object sender, EventArgs e)
{
bool answer = false;
var selectedValue = ordersfilterpicker.Items[ordersfilterpicker.SelectedIndex];
orderinfo tmp_orderinfo = (orderinfo)((Button)sender).BindingContext;
selectedValue = tmp_orderinfo.status;
if (selectedValue == "ALL")
{
answer = await popup_yesno("ACCEPT this delivery ?");
if (answer==true)
{
updateorderstatusrideraccept(tmp_orderinfo.checkoutcode);
refreshlistviewtask();
}
}
else if (selectedValue == "FOR PICKUP")
{
answer = await popup_yesno("START this delivery ?");
if (answer == true)
{
updateorderstatusriderstart(tmp_orderinfo.checkoutcode);
refreshlistviewtask();
}
}
else if (selectedValue == "RELEASED BY LOGISTICS")
{
answer = await popup_yesno("START this delivery ?");
if (answer == true)
{
updateorderstatusriderstart(tmp_orderinfo.checkoutcode);
refreshlistviewtask();
}
}
else if (selectedValue == "RELEASED BY WAREHOUSE")
{
answer = await popup_yesno("START this delivery ?");
if (answer == true)
{
updateorderstatusriderstart(tmp_orderinfo.checkoutcode);
refreshlistviewtask();
}
}
else if (selectedValue == "ONGOING")
{
answer = await popup_yesno("COMPLETE this delivery ?");
if (answer == true)
{
updateorderstatusriderend(tmp_orderinfo.checkoutcode);
refreshlistviewtask();
//I believe I should put something here for the "Nav button" to hide. but I don't know what code to use.
}
}
//("Message", tmp_orderinfo.checkoutcode, "OK");
}
At first, you should give the button a name with the x:Name.首先,您应该使用 x:Name 为按钮命名。 Such as
如
<Button Text="Navigate" Clicked="Button_Clicked" x:Name="button">
Then you can set the IsVisible = false in a clicked event.然后您可以在单击事件中设置 IsVisible = false。 Such as
如
private void Button_Clicked(object sender, EventArgs e)
{
button.IsVisible = false;
}
You can set it in the the "Complete delivery" pressed event.您可以在“完成交付”按下事件中设置它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.