Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin CollectionView项目资源绑定到ContentView_Xamarin_Binding - Fatal编程技术网

Xamarin CollectionView项目资源绑定到ContentView

Xamarin CollectionView项目资源绑定到ContentView,xamarin,binding,Xamarin,Binding,我想将每个CollectionView项绑定到ContentView。但我得到了一个错误: 找不到“文档”的属性、BindableProperty或事件,或者值和属性之间的类型不匹配。 Page.xmal: <CollectionView ItemsSource="{Binding Documents}" > <CollectionView.ItemTemplate> <Data

我想将每个CollectionView项绑定到ContentView。但我得到了一个错误:

找不到“文档”的属性、BindableProperty或事件,或者值和属性之间的类型不匹配。

Page.xmal:

<CollectionView
         ItemsSource="{Binding Documents}"  >
         <CollectionView.ItemTemplate>
               <DataTemplate>
                  <controls:FoldersPageDocumentControl Document="{Binding .}"/>
               </DataTemplate>
         </CollectionView.ItemTemplate>
</CollectionView>
为什么这不起作用?IntelliSense向我展示了
绑定。
属于Document类型,但它不会接受它


编辑:

FoldersPageDocumentControl:

        public Document Document
        {
            get { return (Document)GetValue(DocumentProperty); }
            set { SetValue(DocumentProperty, value); }
        }
        public static readonly BindableProperty DocumentProperty = BindableProperty.Create(
            returnType: typeof(Document),
            propertyName: nameof(Document),
            declaringType: typeof(FoldersPageDocumentControl),
            defaultValue: null );
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:controls="clr-namespace:eTApp.Controls"
    x:DataType="controls:FoldersPageDocumentControl"
    x:Class="eTApp.Controls.FoldersPageDocumentControl">
    <ContentView.Content>
        <Frame
            HasShadow="False"
            BorderColor="#ddd"
            Padding="0,4,16,4"
            CornerRadius="5">
            <StackLayout>
                <Label
                    Margin="16,0,0,4"
                    VerticalOptions="Center"
                    Grid.Column="0"
                    x:Name="labelName"
                    Text="{Binding Name}"
                    FontSize="18"
                    TextColor="{StaticResource TextPrimary}">
                </Label>
            </StackLayout>
        </Frame>
    </ContentView.Content>
</ContentView>

什么是文件?请发布FoldersPageDocumentControl的完整代码?
    public class Document
    {
        public bool DenyAtTextLogin { get; set; }
        public bool Deleted { get; set; }
        public bool Unread { get; set; }
        public bool VerifiedSignatures { get; set; }
        public bool Hidden { get; set; }
        public int AccountID { get; set; }
        public int ID { get; set; }
        public int EncryptionType { get; set; }
        public int FolderID { get; set; }
        public int PageCount { get; set; }
        public int RemoteID { get; set; }
        public int Size { get; set; }
        public int IsChildDocumentOfDocumentID { get; set; }
        public int Type { get; set; }
        public string Extension { get; set; }
        public string Name { get; set; }
        public DateTime CreationDate { get; set; }
        public DateTime Level2StorageDate { get; set; }
        public DateTime ProtectionDate { get; set; }
    }
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:controls="clr-namespace:eTApp.Controls"
    x:DataType="controls:FoldersPageDocumentControl"
    x:Class="eTApp.Controls.FoldersPageDocumentControl">
    <ContentView.Content>
        <Frame
            HasShadow="False"
            BorderColor="#ddd"
            Padding="0,4,16,4"
            CornerRadius="5">
            <StackLayout>
                <Label
                    Margin="16,0,0,4"
                    VerticalOptions="Center"
                    Grid.Column="0"
                    x:Name="labelName"
                    Text="{Binding Name}"
                    FontSize="18"
                    TextColor="{StaticResource TextPrimary}">
                </Label>
            </StackLayout>
        </Frame>
    </ContentView.Content>
</ContentView>
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class FoldersPageDocumentControl : ContentView
    {
        public FoldersPageDocumentControl()
        {
            InitializeComponent();
        }
        

        public Document Document
        {
            get { return (Document)GetValue(DocumentProperty); }
            set { SetValue(DocumentProperty, value); }
        }
        public static readonly BindableProperty DocumentProperty = BindableProperty.Create(
            returnType: typeof(Document),
            propertyName: nameof(Document),
            declaringType: typeof(FoldersPageDocumentControl),
            defaultValue: null );



        public string Name { get { return Document?.Name; } }
    }