此Xamarin表单内容页中的这一空行来自何处?
下图来自Xamarin表单应用程序。请注意绿色和红色区域之间的白色区域。我想知道这个白色区域是从哪里来的?我想绿色和红色会紧靠在一起 下面是生成上述内容的代码。我正在使用一个控制模板,这是我的设计的一个要求(我正在使用一个BoxView来说明这个问题的问题) 基类-XAML此Xamarin表单内容页中的这一空行来自何处?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,下图来自Xamarin表单应用程序。请注意绿色和红色区域之间的白色区域。我想知道这个白色区域是从哪里来的?我想绿色和红色会紧靠在一起 下面是生成上述内容的代码。我正在使用一个控制模板,这是我的设计的一个要求(我正在使用一个BoxView来说明这个问题的问题) 基类-XAML <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WP.MobileMidstream.Device.Pages.DialogBase"
Visual="Material"
>
<ContentPage.ControlTemplate>
<ControlTemplate>
<StackLayout>
<BoxView BackgroundColor="Green" />
<ContentPresenter VerticalOptions="FillAndExpand"
BackgroundColor="Red" />
</StackLayout>
</ControlTemplate>
</ContentPage.ControlTemplate>
</ContentPage>
正在显示的扩展DialogBase的页面
<?xml version="1.0" encoding="utf-8" ?>
<d:DialogBase xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="clr-namespace:WP.MobileMidstream.Device.Pages"
x:Class="WP.MobileMidstream.Device.Pages.AdjustmentEditPage">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</d:DialogBase>
这是应用程序加载时显示的第一页
public partial class App : Application
{
public App()
{
InitializeComponent();
ContainerRegistration.Register();
try
{
// register main container navigation
var mainPage = FreshPageModelResolver.ResolvePageModel<AdjustmentEditPageModel>();
var mainNavigation = new FreshNavigationContainer(mainPage, NavigationContainerNames.DailyRunSheet);
mainNavigation.BarBackgroundColor = Color.FromRgb(0, 69, 140);
mainNavigation.BarTextColor = Color.White;
MainPage = mainNavigation;
}
catch (Exception ex)
{
}
}
公共部分类应用程序:应用程序
{
公共应用程序()
{
初始化组件();
ContainerRegistration.Register();
尝试
{
//注册主集装箱导航
var mainPage=FreshPageModelResolver.ResolvePageModel();
var mainNavigation=新的FreshNavigationContainer(主页,NavigationContainerNames.DailRunSheet);
mainNavigation.BarBackgroundColor=Color.FromRgb(0,69,140);
mainNavigation.BarTextColor=Color.White;
主页=主导航;
}
捕获(例外情况除外)
{
}
}
}您需要使用:
<StackLayout Spacing="0">
<BoxView BackgroundColor="Green" />
<ContentPresenter VerticalOptions="FillAndExpand"
BackgroundColor="Red" />
</StackLayout>
您需要使用:
<StackLayout Spacing="0">
<BoxView BackgroundColor="Green" />
<ContentPresenter VerticalOptions="FillAndExpand"
BackgroundColor="Red" />
</StackLayout>
StackLayout默认设置了Spacing属性,我认为是6。尝试在基本页的ControlTemplate内的StackLayout上显式地说Spacing=“0”。StackLayout默认设置了Spacing属性,我认为是6。尝试在基本页上的ControlTemplate内的StackLayout上显式地说Spacing=“0”。