0
Team, I have a question. I am developing a detail screen of an order, where there is a button used to take this order.
To make it clearer, this detail screen behaves in different ways to different status:
using CoreGraphics;
using MvvmCross.Binding.BindingContext;
using MvvmCross.Core.ViewModels;
using MvvmCross.iOS.Views;
using UIKit;
using Valdemar.Core.ViewModels;
namespace Valdemar.IOs
{
public sealed partial class DetailView : MvxViewController<DetailViewModel>
{
private bool _constructed;
public DetailView() : base("DetailView", null)
{
ViewDidLoad();
}
public override void DidReceiveMemoryWarning()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
if (ViewModel == null)
{
return;
}
var close = UIButton.FromType(UIButtonType.System);
close.Frame = new CGRect(8, 35, 50, 20);
close.SetTitle("Voltar", UIControlState.Normal);
Add(close);
/*
* Binding
*/
var set = this.CreateBindingSet<DetailView, Core.ViewModels.DetailViewModel>();
set.Bind(lblWhat).To(vm => vm.Item.itemsDes);
set.Bind(lblHowMuch).To(vm => vm.Item.valueDes);
set.Bind(lblWhen).To(vm => vm.Item.limitTime);
set.Bind(lblStatus).To(vm => vm.Item.status);
set.Bind(lblUser).To(vm => vm.Item.usersTOByIdClientUser.personsTO.namePerson);
//set.Bind(lblAdress).To(vm => vm.Item.usersTOByIdClientUser);
set.Bind(lblResponsible).To(vm => vm.Item.valdecoOwner);
set.Bind(lblConfirmed).To(vm => vm.Item.confirmed);
set.Bind(lblCreated).To(vm => vm.Item.created);
set.Bind(close).To(vm => vm.CloseCommand);
set.Bind(close).For("Clicked").To(vm => vm.CloseCommand);
if (lblStatus.Text == "A")
{
btnAction.SetTitle("Assumir Pedido!", UIControlState.Normal);
set.Bind(btnAction).To(vm => vm.BtnAssumeCommand);
lblStatus.Hidden = true;
lblConfirmation.Hidden = true;
lblResponsible.Hidden = true;
}
else if (lblStatus.Text == "V")
{
set.Bind(lblStatus).To(vm => vm.V);
btnAction.SetTitle("Entreguei!", UIControlState.Normal);
set.Bind(btnAction).To(vm => vm.BtnDeliverCommand);
lblConfirmation.Hidden = true;
}
else if (lblStatus.Text == "E")
{
set.Bind(lblStatus).To(vm => vm.E);
lblConfirmation.Hidden = false;
btnAction.Hidden = true;
}
else if (lblStatus.Text == "C")
{
lblConfirmation.Hidden = true;
btnAction.Hidden = true;
lblConfirmed.Hidden = false;
set.Bind(lblStatus).To(vm => vm.C);
}
set.Apply();
}
}
}
When I trigger the button command, I will have to change the status of my request, and consequently hide the "Take Over button".
private async Task<bool> assumeOrder()
{
var response = await orderService.assumeResp(getOrder());
if (response == null)
{
messageService.showMessage("Pedido " + Item.id + " assumido com sucesso!");
orderService.deleteAvailableOrder(Item);
RaisePropertyChanged(() => Item);
return false;
}
return true;
}
What’s the best way to do it, especially the "disappear" button? I am trying through Raisepropertychanged(() => Item), it updates the properties, but does not access the View again to change it according to its new Status.
I don’t know if I got it right
xaml
would have to define the propertyIsVisible="{Binding OcultarBotao, Mode=TwoWay}"
to hide a button.– rubStackOverflow