我不知道我的代碼有什麼問題。有人可以檢查我的代碼失敗/錯誤?我正在嘗試與聯繫人列表。當我點擊郵件時,我想發一封郵件到我點擊的地址。與電話號碼相同。 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 = "[email protected]",
Tlfnr = 12345678,
},
new Kontakter
{
Fuldenavn = "Anja (ANBI)",
Email = "[email protected]",
Tlfnr = 87654321,
},
new Kontakter
{
Fuldenavn = "Benn (BMR)",
Email = "[email protected]",
Tlfnr = 12876534,
},
new Kontakter
{
Fuldenavn = "Christian (CBE)",
Email = "[email protected]",
Tlfnr = 18273645,
},
};
return kontakter;
}
}
}
,當您運行此操作時會得到哪些錯誤?你的結果是什麼,你的預期結果是什麼? –
問題是,我沒有任何錯誤,我開始程序之前。但是當我點擊任何電子郵件或電話號碼時,它會崩潰。就像照片一樣。 @CodeWarrior –
錯誤信息非常清晰 - 轉換失敗。您需要弄清楚發件人的實際類型,顯然標籤不正確。 – Jason