Xamarin.forms Xamarin EntryCell ClearValue用途?

Xamarin.forms Xamarin EntryCell ClearValue用途?,xamarin.forms,Xamarin.forms,在Xamarin和Xamarin.Forms新增 我找不到有关EntryCell.ClearValue(BindableProperty p)的任何文档 我想在用户进入第一个EntryCell时清除第二个EntryCell firstcellEntryCell.Tapped += (sender, e) => secondEntryCell.ClearValue(EntryCell.TextProperty); 这是否有意义,或者这不是EntryCell.ClearValue的预期用途?

在Xamarin和Xamarin.Forms新增

我找不到有关EntryCell.ClearValue(BindableProperty p)的任何文档

我想在用户进入第一个EntryCell时清除第二个EntryCell

firstcellEntryCell.Tapped += (sender, e) => secondEntryCell.ClearValue(EntryCell.TextProperty);

这是否有意义,或者这不是EntryCell.ClearValue的预期用途?

为了简单起见,我在Xamarin表单文档中使用了tableview示例:

namespace EntryCellTest
{
    public class EntryCellTestView : ContentPage
    {
        public EntryCellTestView ()
        {
            this.BindingContext = new EntryCellTestViewModel ();

            Label header = new Label {
                Text = "EntryCell",
                Font = Font.BoldSystemFontOfSize (50),
                HorizontalOptions = LayoutOptions.Center
            };

            var entryCell1 = new EntryCell {
                Label = "EntryCell1:",
                Placeholder = "Type Text Here"
            };
            entryCell1.SetBinding(EntryCell.TextProperty, new Binding("EntryText1", BindingMode.TwoWay));

            var entryCell2 = new EntryCell {
                Placeholder = "Type Text Here"
            };
//          entryCell2.SetBinding (EntryCell.TextProperty, "EntryText2",BindingMode.TwoWay);
            entryCell2.SetBinding(EntryCell.TextProperty, new Binding("EntryText2", BindingMode.TwoWay));
            entryCell2.SetBinding (EntryCell.LabelProperty, "EntryTextLabelProperty");

            TableView tableView = new TableView {
                Intent = TableIntent.Form,
                Root = new TableRoot {
                    new TableSection {
                        entryCell1,
                        entryCell2
                    }
                }
            };

            // Accomodate iPhone status bar.
            this.Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout {
                Children = {
                    header,
                    tableView
                }
            };
        }
    }

    public class EntryCellTestViewModel : INotifyPropertyChanged
    {
        public EntryCellTestViewModel ()
        {
            this.EntryTextLabelProperty = "Just a test";
        }

        private string entryTextLabelProperty;

        public string EntryTextLabelProperty {
            get {
                return entryTextLabelProperty;
            }
            set {
                entryTextLabelProperty = value;
                OnPropertyChanged ("EntryTextLabelProperty");
            }
        }

        private string entryText1;

        public string EntryText1 {
            get {
                return entryText1;
            }
            set {
                entryText1 = value;
                OnPropertyChanged ("EntryText1");
            }
        }

        private string entryText2;

        public string EntryText2 {
            get {
                return entryText2;
            }
            set {
                entryText2 = value;
                this.EntryText1 = "";
                OnPropertyChanged ("EntryText2");
            }
        }


        #region INotifyPropertyChanged implementation

        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged ([CallerMemberName]string propertyName = null)
        {
            if (PropertyChanged != null) {
                PropertyChanged (this, new PropertyChangedEventArgs (propertyName));
            }
        }

        #endregion
    }

}

显然,您需要改变绑定和setter逻辑以达到预期的结果。

Sierra Hotel-欠您一杯啤酒