Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

ListView.ItemTapped not working when GroupHeaderTemplate is set in custom renderer (WP8)

$
0
0

Hi everyone

Firstly, thank you very much for the greate work you do. Xamarin form is definitly the best approach for cross platform development I have seen yet!

I try to create an application with a grouped ListView where the HeaderTemplate is red and uses the whole width of the screen (in WP8).
It was not possible for me to do this in xamarin.forms so I decided to implement a custom renderer.
But when replacing the GroupHeaderTemplate with an own implementation from the global application resource dictionary of the app.xaml, the ItemTapped will no longer fire. Furthermore I noticed that the data binding is no longer working.

To demonstrate this, I tried the same thing with the LabelledSectionList example and madethe following modifications:

Defining a DataTemplate inside the App.xaml of the WP8 Project:

<DataTemplate x:Key="GroupHeaderTemplate">
            <Border Background="Red" Height="48">
                <TextBlock Text="{Binding Title}" Foreground="White" FontSize="32"/>
            </Border>
</DataTemplate>

Then I created a custom renderer for the ListView:

[assembly: ExportRenderer(typeof(ListView), typeof(MyListViewRenderer))]
namespace LabelledSections.WinPhone
{
    class MyListViewRenderer : ListViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
        {
            base.OnElementChanged(e);
            Control.Name = "MyListView";
            Control.GroupHeaderTemplate = Application.Current.Resources["GroupHeaderTemplate"] as System.Windows.DataTemplate;
        }
    }
}

As you can see in the screenshot, the DataTemplate is applied. But when I tap no on a listview item, the tap event will be no longer fired. Am I doing something wrong or is this a bug?

Furthermore the binding is no longer working.

Best Regards
Chris


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>