【发布时间】:2020-10-24 09:49:05
【问题描述】:
我已经实现了一个按钮,它需要一个函数。该函数实际上向服务器发送一个请求以颁发证书。当用户收到凭据时,凭据状态为已提供,但当她/他单击此按钮时,它会向服务器发送请求,并且按钮状态更改为已接收 .
我只想在按钮状态为Offered时显示按钮。
CredentialPage.xml
<Button x:Name="Button_Round"
WidthRequest="40"
HeightRequest="40"
CornerRadius="20"
BorderWidth="2"
TextColor="White"
BorderColor="Teal"
BackgroundColor="Teal"
Text="Accept Offer"
Command="{Binding ProcessOffer}" />
CredentialViewModel.cs => CreateRequestAsync() 是一个,它将请求发送到服务器。当请求发送成功后,我想隐藏按钮。
public ICommand ProcessOffer => new Command(async () =>
{
try
{
//await _poolConfigurator.ConfigurePoolsAsync();
var agentContext = await _agentContextProvider.GetContextAsync();
var credentialRecord = await _credentialService.GetAsync(agentContext, _credential.Id);
var connectionId = credentialRecord.ConnectionId;
var connectionRecord = await _connectionService.GetAsync(agentContext, connectionId);
(var request, _) = await _credentialService.CreateRequestAsync(agentContext, _credential.Id);
await _messageService.SendAsync(agentContext.Wallet, request, connectionRecord);
await DialogService.AlertAsync("Request has been sent to the issuer.", "Success", "Ok");
}
catch (Exception e)
{
await DialogService.AlertAsync("Pool is not correctly configured. Please add proper genesis file.\n("+e.Message+")","Pool Error","Ok");
}
});
如果你能指导我,你会很友善:)
【问题讨论】:
-
创建一个你的按钮可以观察到启用/禁用的布尔属性,然后在你的函数调用之前/之后设置该布尔属性
-
你能用一点代码指导我吗,我对xamarin不太了解。
-
@MattGreen 您好,如果回复有帮助,请不要忘记接受它作为答案(点击此答案左上角的✔),它将帮助有类似问题的其他人。 :-)
标签: c# .net visual-studio xamarin xamarin.forms