C# 值未在自定义控件可绑定属性-Xamarin forms/Prism中更新

C# 值未在自定义控件可绑定属性-Xamarin forms/Prism中更新,c#,mvvm,xamarin.forms,custom-controls,prism,C#,Mvvm,Xamarin.forms,Custom Controls,Prism,我创建了一个自定义控件,它在StackControl中有一个条目和一个标签。然后,我通过一个名为IsEntryEnabled的可绑定属性公开了条目的IsEnabled属性,我想将该属性绑定到VM的bool属性。但它从不触发。知道我做错了什么吗 自定义控件-Xaml <ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/win

我创建了一个自定义控件,它在StackControl中有一个条目和一个标签。然后,我通过一个名为IsEntryEnabled的可绑定属性公开了条目的IsEnabled属性,我想将该属性绑定到VM的bool属性。但它从不触发。知道我做错了什么吗

自定义控件-Xaml

<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:effects="clr-namespace:VMSTablet.Effects;assembly=VMSTablet"
             x:Class="VMSTablet.Controls.StandardFormEntry">
    <StackLayout >
        <Label  Text="{Binding LabelText}" Style="{StaticResource DefaultLabelStyle}" TextColor="{StaticResource DarkGreenColor}"/>
        <Entry x:Name="CustomEntry" Text="{Binding Text}" 
               IsEnabled="{Binding IsEntryEnabled}" 
               Keyboard="{Binding Keyboard}" 
               Behaviors="{Binding Behaviors}" 
               TextColor="{StaticResource DarkGreenColor}"
               Placeholder="{Binding Placeholder}" Style="{StaticResource DefaultEntryStyle}" >
            <Entry.Effects>
                <effects:EntryBarColorEffect/>
            </Entry.Effects>
        </Entry>
    </StackLayout>
</ContentView>
查看

我将IsEditingEnabled属性绑定到自定义控件中的IsEntryEnabled属性,该属性应该触发内部条目中的IsEnabled属性。但它从不触发

 <controls:StandardFormEntry IsEntryEnabled="{Binding IsEditingEnabled}" EntryText="{Binding Text}" LabelText="Name" Grid.Column="0" Grid.Row="3"/>

在自定义控件中,您需要为内容视图指定一个名称,并将该名称引用到绑定属性的源,如下所示:

<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:effects="clr-namespace:VMSTablet.Effects;assembly=VMSTablet"
         x:Class="VMSTablet.Controls.StandardFormEntry"
         x:Name="CustomEntryControl">
<StackLayout >
    <Label  Text="{Binding LabelText}" Style="{StaticResource DefaultLabelStyle}" TextColor="{StaticResource DarkGreenColor}"/>
    <Entry x:Name="CustomEntry" Text="{Binding Text}" 
           IsEnabled="{Binding IsEntryEnabled, Source={x:Reference CustomEntryControl}}" 
           Keyboard="{Binding Keyboard}" 
           Behaviors="{Binding Behaviors}" 
           TextColor="{StaticResource DarkGreenColor}"
           Placeholder="{Binding Placeholder}" Style="{StaticResource DefaultEntryStyle}" >
        <Entry.Effects>
            <effects:EntryBarColorEffect/>
        </Entry.Effects>
    </Entry>
</StackLayout>


为什么不通过Create方法的PropertyChanged参数跟踪可绑定属性的值更改?和我一样。它也没有开火。
 <controls:StandardFormEntry IsEntryEnabled="{Binding IsEditingEnabled}" EntryText="{Binding Text}" LabelText="Name" Grid.Column="0" Grid.Row="3"/>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:effects="clr-namespace:VMSTablet.Effects;assembly=VMSTablet"
         x:Class="VMSTablet.Controls.StandardFormEntry"
         x:Name="CustomEntryControl">
<StackLayout >
    <Label  Text="{Binding LabelText}" Style="{StaticResource DefaultLabelStyle}" TextColor="{StaticResource DarkGreenColor}"/>
    <Entry x:Name="CustomEntry" Text="{Binding Text}" 
           IsEnabled="{Binding IsEntryEnabled, Source={x:Reference CustomEntryControl}}" 
           Keyboard="{Binding Keyboard}" 
           Behaviors="{Binding Behaviors}" 
           TextColor="{StaticResource DarkGreenColor}"
           Placeholder="{Binding Placeholder}" Style="{StaticResource DefaultEntryStyle}" >
        <Entry.Effects>
            <effects:EntryBarColorEffect/>
        </Entry.Effects>
    </Entry>
</StackLayout>