<Frame HasShadow="False" Grid.RowSpan="2" StyleClass="framelbl" BackgroundColor="{Binding MtypeColor}" Grid.ColumnSpan="2" HorizontalOptions="End" Grid.Column="1">
<Frame.GestureRecognizers>
<TapGestureRecognizer CommandParameter="{Binding .}" Tapped="OnFrameClick" NumberOfTapsRequired="1" />
</Frame.GestureRecognizers>
<Label x:Name="pdd" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Text="{Binding Mtype}"/>
private void OnFrameClick(object sender, EventArgs e)
{
var selecteditems = (Frame)sender;
var classId = selecteditems.GestureRecognizers[0];
var test = classId;
var testin = ((TapGestureRecognizer)test).CommandParameter;
var shipments = (Shipment)testin;
//var ahipment = (e.Parameter) as Shipment;
}
This actually works but this code is bad to say the least. I'm hoping someone can show me how to write this and get the object Shipment From the (object sender) cleanly.
This is what I need and it works but the code syntax is subpar at best if anyone has any suggestions.
<Frame HasShadow="False" Grid.RowSpan="2" StyleClass="framelbl" BackgroundColor="{Binding MtypeColor}" Grid.ColumnSpan="2" HorizontalOptions="End" Grid.Column="1">
<Frame.GestureRecognizers>
<TapGestureRecognizer CommandParameter="{Binding .}" Tapped="OnFrameClick" NumberOfTapsRequired="1" />
</Frame.GestureRecognizers>
<Label x:Name="pdd" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Text="{Binding Mtype}"/>
private void OnFrameClick(object sender, EventArgs e)
{
var selecteditems = (Frame)sender;
var classId = selecteditems.GestureRecognizers[0];
var test = classId;
var testin = ((TapGestureRecognizer)test).CommandParameter;
var shipments = (Shipment)testin;
//var ahipment = (e.Parameter) as Shipment;
}
This actually works but this code is bad to say the least. I'm hoping someone can show me how to write this and get the object Shipment From the (object sender) cleanly.
This is what I need and it works but the code syntax is subpar at best if anyone has any suggestions.
You're using the wrong EventArgs class. You need TappedEventArgs
private void OnFrameClick(object sender, TappedEventArgs e)
{
if(e.Parameter is Shipment shipment)
{
//TODO
}
}
Frame
is marked as obsolete in .NET MAUI 9, and will be completely removed in a future release. UseBorder
instead. – Felix Shen Commented Feb 14 at 8:50