具有多列的 Xamarin Forms Shell Flyout

问题描述

我有一个业务需求,需要构建一个包含多列的弹出菜单。该菜单将具有所有基本弹出行为,它必须在左侧有一个狭窄的静态列,其中包含 3 个按钮,然后在其旁边有常规的可滚动弹出菜单。此时是否可以在 xamarin 表单外壳中为弹出窗口执行完全自定义的布局?

enter image description here

解决方法

您可以使用 FlyoutContentTemplate 来做到这一点。

 <Shell.FlyoutContentTemplate>
    <DataTemplate>
       
        <StackLayout Orientation="Horizontal">
            <StackLayout BackgroundColor="Purple">
                <Button Text="home" />
                <Button Text="dash" />
                <Button Text="chat" />
            </StackLayout>
            <CollectionView
                BindingContext="{x:Reference shell}"
                IsGrouped="True"
                ItemsSource="{Binding FlyoutItems}">
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Label
                            FontSize="Large"
                            Text="{Binding Title}"
                            TextColor="Black" />

                    </DataTemplate>
                </CollectionView.ItemTemplate>
            </CollectionView>

        </StackLayout>
    </DataTemplate>
</Shell.FlyoutContentTemplate>

enter image description here

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...