C
C#11mo ago
r2d25551

❔ Guid from TappedEventArgs

For the TapGestureRecognizer event handler I am passing in a GUID. I have not figured out how to convert the TappedEventArgs.Parameter to a GUID:
protected async void OnItemSelected(object sender, TappedEventArgs args)
{
Guid guid = args.Parameter as Guid;
}
protected async void OnItemSelected(object sender, TappedEventArgs args)
{
Guid guid = args.Parameter as Guid;
}
Any help is appreciated.
4 Replies
r2d25551
r2d2555111mo ago
protected async void OnItemSelected(object sender, TappedEventArgs args)
string guidStr = args.Parameter.ToString();
if (string.IsNullOrEmpty(guidStr)) return;
Guid guid = Guid.Empty;
Guid.TryParse(guidStr, out guid);
protected async void OnItemSelected(object sender, TappedEventArgs args)
string guidStr = args.Parameter.ToString();
if (string.IsNullOrEmpty(guidStr)) return;
Guid guid = Guid.Empty;
Guid.TryParse(guidStr, out guid);
Mayor McCheese
Mayor McCheese11mo ago
What type is Parameter?
protected async void OnItemSelected(object sender, TappedEventArgs args)
{
if(!string.IsNullOrWhiteSpace(args.Parameter) && Guid.TryParse(guidStr, out var guid))
{
// This is now a valid guid
}
protected async void OnItemSelected(object sender, TappedEventArgs args)
{
if(!string.IsNullOrWhiteSpace(args.Parameter) && Guid.TryParse(guidStr, out var guid))
{
// This is now a valid guid
}
r2d25551
r2d2555111mo ago
Funny, debugger shows object {System.Guid} as I thought it should be:
args.Parameter {966ebbb6-124e-4044-a788-1f927c9a4107} object {System.Guid}
args.Parameter {966ebbb6-124e-4044-a788-1f927c9a4107} object {System.Guid}
Accord
Accord11mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts