是否可以访问XAML中的自定义控件的内部控件?

时间:2019-05-01 22:29:06

标签: xaml xamarin

我有一个自定义控件PickerWithDropdownIcon,它是一个AbsoluteLayout,其中包含Picker和其他控件。我想知道是否有一种方法可以从使用Picker控件的XAML访问内部PickerWithDropdownIcon

PickerWithDropdownIcon.xaml:

<AbsoluteLayout xmlns="http://xamarin.com/schemas/2014/forms" 
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:svg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
                x:Class="CollateralUploader.XAMLHelpers.PickerWithDropdownIcon">

  <Picker x:Name="InnerPicker" />

  <svg:SvgCachedImage AbsoluteLayout.LayoutBounds="1,0.5,-1,-1" AbsoluteLayout.LayoutFlags="PositionProportional"
                                Source="resource://CollateralUploader.Images.icon-down_arrow.svg">
    <svg:SvgCachedImage.GestureRecognizers>
      <TapGestureRecognizer Tapped="PickerArrow_Tapped" />
    </svg:SvgCachedImage.GestureRecognizers>
  </svg:SvgCachedImage>

</AbsoluteLayout>

在我的View中,我想做这样的事情:

<xh:PickerWithDropdownIcon>
  <InnerPicker.SelectedItem="{Binding VehicleNumberText}" />
  <InnerPicker.Items>
    <x:String>Vehicle 1</x:String>
    <x:String>Vehicle 2</x:String>
  </Picker.Items>
</xh:PickerWithDropdownIcon>

有可能做这样的事情吗?

0 个答案:

没有答案