0

I have a xamarin forms application and I want to add a footer to the flyout menu. After reading the official documentation it should be straightforward, just adding a few lines into the AppShell.xaml like so:

<Shell.FlyoutFooterTemplate>
    <DataTemplate>
        <Label HeightRequest="300" BackgroundColor="Red"/>
    </DataTemplate>
</Shell.FlyoutFooterTemplate>

This works perfectly fine when I tried it in a new project, but for some reason, it doesn't work in my current application giving this error: Error XLS0415 The attachable property 'FlyoutFooterTemplate' was not found in type 'Shell'.

I tried to find the definition of FlyoutHeaderTemplate and I found this in Shell [from metadata] file: [1]: https://i.stack.imgur.com/xqZub.png

public Shell();
...
public DataTemplate FlyoutHeaderTemplate { get; set; }
public FlyoutHeaderBehavior FlyoutHeaderBehavior { get; set; }
public object FlyoutHeader { get; set; }

There should be a similar definition for both, Header and Footer, but there is only one for the Header. The file cannot be edited and I was not able to locate it either. Any ideas why the definition for Footer is missing, how can I add it, or workarounds?

PS: Adding the footer from C# code doesn't work either and I tried to clean/rebuild and resetting both, PC and VS.

1 Answers1

0

First, Confirm that you can add a simple Header:

<Shell.FlyoutHeader>
    <Label Text="This is the header." />
</Shell.FlyoutFooter>

If that doesn't work, then you are doing something fundamentally wrong - post the code for the <Shell> XAML, within which you added those lines. Make sure you include those lines, to show where in the XAML they are. Make sure they are between <Shell> and </Shell>, but not nested inside some deeper node. For example, they musn't be inside a <StackLayout> or <ContentView> or other container - they must be direct children of the <Shell>.


Unless you are doing something fancy, you don't need a Template.

Try simply:

<Shell.FlyoutFooter>
    <Label HeightRequest="300" BackgroundColor="Red"/>
</Shell.FlyoutFooter>

If 1) above works, but not 2), then your project is referencing an out-of-date version of Shell. Fixes:

A. Check that project's Xamarin.Forms nuget doesn't need an Update. (Solution / Manage Nugets.)
B. OR delete bin and obj folders. Then Rebuild Solution.
C. Worst case, start with a new project, in which you are able to use that functionality, and add back in all your files.

ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196
  • 1
    I just found out myself too, I have an old Xamarin version (4.6), the footer was added in version 5 as said here: https://newreleases.io/project/github/xamarin/Xamarin.Forms/release/beta-5.0.0-pre3 Thank you. – Tomáš Martínek Jul 06 '21 at 11:08