Xamarin 如何从XfxEntry获取文本?

Xamarin 如何从XfxEntry获取文本?,xamarin,c#-4.0,xamarin.forms,Xamarin,C# 4.0,Xamarin.forms,我在vs 2017 professional中使用过Xamrin。 我想在跨平台应用程序中使用浮动文本视图 我使用了下面的链接,但它没有描述如何从中获取文本 [连结] Main.xaml <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:xfx="cl

我在vs 2017 professional中使用过Xamrin。 我想在跨平台应用程序中使用浮动文本视图

我使用了下面的链接,但它没有描述如何从中获取文本

[连结]

Main.xaml

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:xfx="clr-namespace:Xfx;assembly=Xfx.Controls"
             x:Class="Reports_Rpt.Signup">
    <NavigationPage.TitleView>
        <StackLayout Orientation="Horizontal" VerticalOptions="Center" Spacing="10" BackgroundColor="#4B8CA8">
            <Image Source="iconXamagon.png">
            </Image>

        </StackLayout>
    </NavigationPage.TitleView>
    <ContentPage.Content>
        <StackLayout Padding="2,2,2,2" BackgroundColor="White">
            <StackLayout Orientation="Horizontal" VerticalOptions="Start" HorizontalOptions="FillAndExpand">
                <xfx:XfxEntry 

                          Placeholder="Enter your name"
                          Text="{Binding Name}"
                          ErrorText="{Binding NameErrorText}" />
            </StackLayout>

        </StackLayout>
    </ContentPage.Content>
</ContentPage>

您已将Text属性绑定到Name,因此模型的Name属性应包含该文本

或者,您可以为控件指定名称并以这种方式引用它

<xfx:XfxEntry x:Name="myEntry" Placeholder="Enter your name"
              Text="{Binding Name}" 
              ErrorText="{Binding NameErrorText}" />

看起来您正在使用数据绑定,因此文本应该位于
Name
属性中
var value = myEntry.Text;