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

Custom controls not working in ListView.HeaderTemplate

$
0
0

I have a list that has a custom control used in it, and it works great, but for some reason I can't use the control in the ListView.HeaderTemplate. I am passing in a Binding of ".", because if I don't pass anything in, it won't show the header. Anyone know how to get this to work?

My Code:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:ctrls="clr-namespace:MyApp.Controls;assembly=MyApp" xmlns:local="clr-namespace:MyApp;assembly=MyApp" x:Class="MyApp.Views.HomePage" IsBusy="{Binding IsBusy}">
<ContentPage.Content>
        <!--- Content -->
            <StackLayout Spacing="0" VerticalOptions="FillAndExpand">
                <!--- List -->
                <ListView ItemsSource="{Binding MyList}" SeparatorVisibility="None" IsPullToRefreshEnabled="true" RefreshCommand="{Binding RefreshMyListCommand}" IsRefreshing="{Binding IsRefreshing, Mode=OneWay}" ItemAppearing="OnItemAppearing" ItemSelected="OnItemSelected" RowHeight="100" Header="{Binding .}" BackgroundColor="Transparent">
                    <ListView.HeaderTemplate>
                    <DataTemplate>
                                <StackLayout Spacing="0" BackgroundColor="Transparent">
                                <ctrls:Shadow Direction="up" EndPoint="0.7" HeightRequest="80" Opacity="1" />
                                <Label Text="Test" />
                            </StackLayout>
                            </DataTemplate>
                </ListView.HeaderTemplate>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <ViewCell.View>
                                    <StackLayout>
                                        <ctrls:Shadow Direction="up" EndPoint="0.7" HeightRequest="80" Opacity="1" />
                                        <Label Text="Test" />
                                    </StackLayout>
                                </ViewCell.View>
                                </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                <!--- /List -->
            </StackLayout>
    <!--- /Content -->
</ContentPage.Content>


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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