我不知道我的代码有什么问题。有人可以检查我的代码是否有失败/错误?我正在尝试列出联系人列表。当我点击电子邮件时,我想发送邮件到我点击的地址。与电话号码相同。 When I tap Email or Tlfnr
我的xaml.CS代码:
private void OnEmailTapped(object sender, EventArgs e)
{
var emailMessenger = CrossMessaging.Current.EmailMessenger;
if (emailMessenger.CanSendEmail)
{
emailMessenger.SendEmail(to: ((Label)sender).Text);
}
}
我的Xaml代码:
<StackLayout x:Name="EmailTapped">
<Label x:Name="OnEmailTapped" Text="{Binding Email}" TextColor="Black" FontSize="Medium" />
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="OnEmailTapped" CommandParameter="{Binding Email}"/>
</Label.GestureRecognizers>
</StackLayout>
我的联系人:
namespace App3
{
public class Kontakter
{
public string Fuldenavn { get; set; }
public string Tlfnr { get; set; }
public string Email { get; set; }
public List<Kontakter> GetKontakter()
{
List<Kontakter> kontakter = new List<Kontakter>
{
new Kontakter
{
Fuldenavn = "bacon (ANSE)",
Email = "Random@gmail.com",
Tlfnr = 12345678,
},
new Kontakter
{
Fuldenavn = "Anja (ANBI)",
Email = "Random@hotmail.dk",
Tlfnr = 87654321,
},
new Kontakter
{
Fuldenavn = "Benn (BMR)",
Email = "Random@hotmail.com",
Tlfnr = 12876534,
},
new Kontakter
{
Fuldenavn = "Christian (CBE)",
Email = "Nothing@gmail.com",
Tlfnr = 18273645,
},
};
return kontakter;
}
}
}