我基本上想在我的 Xamarin 表單 UWP 應用程式中減小抽屜的大小。我有一個 FlyoutPage 和一個自定義渲染器,但我找不到抽屜大小的屬性。我想我完全迷失在 Xamarin Forms 上,因為我是初學者和非英語母語者。
所以,這是我的代碼:
FlyoutMenuPage.xaml
'''
<?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:local="using:FlyoutPageNavigation"
x:Class="FlyoutPageNavigation.FlyoutMenuPage"
Padding="0,20,0,0"
IconImageSource=""
Title="Random"
>
<StackLayout >
<ListView x:Name="listView" x:FieldModifier="public">
<ListView.ItemsSource>
<x:Array Type="{x:Type local:FlyoutPageItem}">
<local:FlyoutPageItem Title="Menu" IconSource="" TargetType="{x:Type local:BasePage}" />
<local:FlyoutPageItem Title="Settings" IconSource="" TargetType="{x:Type local:SettingsPage}" />
<local:FlyoutPageItem Title="Information" IconSource="" TargetType="{x:Type local:InformationPage}" />
</x:Array>
</ListView.ItemsSource>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="5,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="{Binding IconSource}" />
<Label Grid.Column="1" Text="{Binding Title}" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
'''
自定義渲染器
我試圖在這里添加一些代碼來確定抽屜的大小,但沒有任何效果,所以我洗掉了所有內容。
'''
[assembly: ExportRenderer(typeof(FlyoutMenuPage), typeof(FlyoutCustomRenderer))]
namespace Random.UWP.Custom_Renderers
{
class FlyoutCustomRenderer : PageRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
{
base.OnElementChanged(e);
if (e.OldElement != null || Element == null)
{
return;
}
}
}
}
'''
謝謝。
uj5u.com熱心網友回復:
如果您需要一個 none-Shell專案,您可以參考以下解決方案。
FlyoutPage
這里的檔案:

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/445080.html
標籤:xamarin xamarin.forms xamarin.uwp
上一篇:foreach不能對“object”型別的變數進行操作,因為“object”不包含“GetEnumerator”的公共實體或擴展定義
