【发布时间】:2015-05-13 00:14:31
【问题描述】:
自定义控件类:
public class CustomTextInput : UITextField
{
}
Xamarin.Forms xaml:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:Custom="clr-namespace:SampleApp.CustomControls;assembly=SampleApp"
x:Name="SampleAppView">
<ContentPage.Content>
<StackLayout Orientation="Horizontal">
<Image Source="Sample_ic.png" WidthRequest="29" HeightRequest="29"/>
<StackLayout Orientation="Vertical">
<Label Text="Sample Text" TextColor="#717073" FontSize="Small" FontFamily="Helvetica"/>
<!--Accessing IOS Custom control class-->
<Custom:CustomTextInput Text="50 Gal" BackgroundColor="Transparent" TextColor="#838288" />
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
我可以在 xamarin.forms xaml 中访问 android/IOS 自定义控件类吗?对于示例,我使用了 UITextField 控件。但我需要访问 xamarin.forms 中不可用的 android/IOS 平台特定的自定义控件。
【问题讨论】:
-
Xamarin.Forms 会将其控件(例如
Entry)呈现为每个特定平台的本机控件,那么您的问题是什么?也许您正在 Xamarin.Forms 中寻找类似 Custome Renderers 的东西? -
没有。我需要呈现 Xamarin.Forms 中不可用的 android/ios 特定控件。
-
我认为你不了解 Xamarin.Forms 的概念,请阅读它的工作原理以及为什么不应该关注 Xamarin.Forms 中的本机控件。
标签: xamarin.forms