Hello,
=============Update==================
You cannot put the if (ChildGirdListItem.GetType() == typeof(Label))
in the if (ChildGirdListItem.GetType() == typeof(CheckBox))
, I move it to the outside of if (ChildGirdListItem.GetType() == typeof(CheckBox))
Please note: I do not know about vcard
SO I move it to foreach
and create two local property string id="", text="";
for testing.
void ButtonGenerateQR_Clicked(System.Object sender, System.EventArgs e)
{
VerticalStackLayout view = ScrollViewDetails.Content as VerticalStackLayout; var VScrollChilds = view.Children;
vcard = new StringBuilder();
vcard.AppendLine("BEGIN:VCARD");
vcard.AppendLine("VERSION:3.0");
vcard.AppendLine("N;CHARSET=utf-8:" + string.Format("{0};{1}", last_name, first_name));
vcard.AppendLine("FN;CHARSET=utf-8:" + string.Format("{0} {1} {2} {3} {4}", prefix, first_name, middle_name, last_name, suffix));
string id="", text="";
foreach (var item in VScrollChilds)
{
VerticalStackLayout childVerticalStacklayout = item as VerticalStackLayout;
if (childVerticalStacklayout != null)
{
var it = childVerticalStacklayout.Children;
foreach (var ChildVStacklayoutItem in it)
{
Grid ChildVSLGrid = ChildVStacklayoutItem as Grid;
var ChildGirdList = ChildVSLGrid.Children;
if (ChildGirdList != null)
{
foreach (var ChildGirdListItem in ChildGirdList)
{
if (ChildGirdListItem.GetType() == typeof(CheckBox))
{
CheckBox childCheckBox = ChildGirdListItem as CheckBox;
if (childCheckBox.IsChecked == true)
{
Console.WriteLine("=========" + childCheckBox.ClassId + "=============");
id = childCheckBox.ClassId;
}
}
if (ChildGirdListItem.GetType() == typeof(Label))
{
Label childLabel = ChildGirdListItem as Label;
Console.WriteLine("=========" + childLabel.Text + "=============");
text = childLabel.Text;
}
vcard.AppendLine(string.Format("{0};PREF;WORK:{1}", id, text));
}
}
}
}
}
vcard.AppendLine("END:VCARD");
Clipboard.SetTextAsync(vcard.ToString());
this.ShowPopup(new ContactQR(vcard.ToString()));
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.