【问题标题】:Xamarin.Forms TableView EntryCell not displaying correctly on UWPXamarin.Forms TableView EntryCell 无法在 UWP 上正确显示
【发布时间】:2018-07-19 16:13:53
【问题描述】:

我有一个非常简单的 Xamarin.Forms 应用程序,仅包含一个带有 Content 的 TableView。

<?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="clr-namespace:TableTest"
         x:Class="TableTest.MainPage">
    <TableView>
        <TableRoot>
            <TableSection Title="Foo">
                <EntryCell Label="Cell1"
                           x:Name="TestCell"/>
                <EntryCell Label="Cell2"
                           x:Name="TestCell2"/>
            </TableSection>
    </TableRoot>
</TableView>

我现在通过重写 OnAppearing() 方法来设置单元格的文本。

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }
    protected override void OnAppearing()
    {
        base.OnAppearing();
        TestCell.Text = "Zazzle";
        TestCell2.Text = "Brrzzz";
    }
}

这在 Android 上运行良好,但使用 UWP 时,第一个 Cell 会显示为折叠状态,并且只有在将鼠标移到单元格上后才会返回到预期的状态。 This is a screenshot of the undesirable result.我做错了什么?

【问题讨论】:

    标签: xamarin.forms


    【解决方案1】:

    试试这个:

    <StackLayout>  
        <Label Text="Entry Cell Demo for Android and UWP (Xamarin.Forms)" VerticalOptions="Center" HorizontalOptions="Center" />  
        <TableView Intent="Form">  
            <TableRoot>  
                <TableSection Title="My Form">  
                    <EntryCell Label="Name:" HorizontalTextAlignment="Start" LabelColor="Black" Placeholder="Enter Name Here" />  
                    <EntryCell Label="City :" LabelColor="Black" Placeholder="Enter City Here" /> </TableSection>  
            </TableRoot>  
        </TableView>  
    </StackLayout>  
    

    参考:this

    【讨论】:

    • Stacklayout 是我缺少的部分,现在它可以按预期工作了。
    • @evasivepi 喜欢编码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-07
    • 2019-09-28
    • 2018-07-21
    • 2017-03-01
    • 1970-01-01
    • 2022-08-16
    相关资源
    最近更新 更多