- Home
- Forum
- Xamarin.Forms
- How to disable navigatin for the ListView group?
How to disable navigatin for the ListView group?
Hi there!
I've implemented the navigation for the tapped list items, but when tapping the group header, it behaves the same way navigating to list detail page. How do I disable the navigation for the group header?
Thank you!
Regards,
Eduardo.
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
LN
Lakshmi Natarajan
Syncfusion Team
November 6, 2020 04:46 AM UTC
Hi Eduardo,
Thank you for using Syncfusion products.
We have checked the reported query “How to disable navigatin for the ListView group” from our side. We would like to inform you that you can get the ItemType from the ItemTappedEventArgs and skip the tapped actions for the GroupHeaderItems. Please find the following code snippets,
PortofolioViewModel
|
public Command<object> ProductSelectedCommand
{
get
{
return new Command<object>(async (sender) =>
{
var args = sender as Syncfusion.ListView.XForms.ItemTappedEventArgs;
//Goto another page for the record items.
if (args.ItemType == Syncfusion.ListView.XForms.ItemType.Record)
await Shell.Current.GoToAsync("ProductDetail");
});
}
} |
Please refer our user guidance document regarding the same,
Please let us know if you need further assistance.
Regards,
Lakshmi Natarajan
EL
Eduardo Luczinski Junior
November 9, 2020 02:39 PM UTC
Hi Lakshmi!
Thank you for the response! This code returns the NullReferenceException and I still didn't figure out how to solve this.
System.NullReferenceException: 'Object reference not set to an instance of an object.'
args is still null although the sender is not. It seems it's not converting sender to a ItemTappedEventArgs.
Regards,
Eduardo.
LN
Lakshmi Natarajan
Syncfusion Team
November 10, 2020 07:24 AM UTC
Hi Eduardo,
Sorry for the inconvenience caused.
We would like to inform you that the default command parameter for the TapCommand is the ItemTappedEventArgs. In your case, you are using custom TapBehavior for the ListView, we suspect that the tapped item’s BindingContext is passed as the parameter for command and caused the reported issue. Could you please share the SfListViewTapBehavior class to check further from our side?
Meanwhile, we suggest you to use the SfListView.TapCommand to overcome the reported scenario. Please refer the documentation regarding the same,
XAML
|
<listView:SfListView x:Name="listView"
ItemsSource="{Binding AssetSummaries}"
AllowGroupExpandCollapse="True"
DragStartMode="OnDragIndicator,OnHold"
AllowSwiping="True"
IsScrollingEnabled="False"
SelectionMode="None"
GroupHeaderSize="60"
AutoFitMode="Height"
TapCommand="{Binding Path=BindingContext.ProductSelectedCommand, Source={x:Reference portfolioView}}"> |
Please let us know if this helps.
Regards,
Lakshmi Natarajan
Marked as answer
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
- Marked answer
-
EL Eduardo Luczinski Junior
- Nov 5, 2020 07:34 PM UTC
- Nov 10, 2020 07:24 AM UTC