1

我将 Telerik 的 WPF 控件与 Caliburn.Micro 一起使用。特别是 DataForm 控件。我正在尝试将其绑定到具有以下组成的对象。

public class FrequencyMap : BindableBase
{
    private Guid id;

    public Guid ID
    {
        get { return id; }
        set
        {
            id = value;
            OnPropertyChanged();
        }
    }

    private string procedureCodeId;

    public string ProcedureCodeId
    {
        get { return procedureCodeId; }
        set
        {
            procedureCodeId = value;
            OnPropertyChanged();
        }
    }

    private FrequencyChoice frequency;

    public FrequencyChoice Frequency
    {
        get { return frequency; }
        set
        {
            frequency = value;
            OnPropertyChanged();
        }
    }

    private DateTime effectiveDate;

    public DateTime EffectiveDate
    {
        get { return effectiveDate; }
        set
        {
            effectiveDate = value;
            OnPropertyChanged();
        }
    }

    private DateTime? terminateDate;

    public DateTime? TerminateDate
    {
        get { return terminateDate; }
        set
        {
            terminateDate = value;
            OnPropertyChanged();
        }
    }
}

然后FrequencyChoice对象看起来像这样:

    public class FrequencyChoice : BindableBase
{
    private int id;

    private string modifiedUser;

    public int ID
    {
        get { return id; }
        set
        {
            id = value; OnPropertyChanged();
        }
    }

    private string code;

    public string Code
    {
        get { return code; }
        set
        {
            code = value; OnPropertyChanged();
        }
    }

    private string name;

    public string Name
    {
        get { return name; }
        set
        {
            name = value; OnPropertyChanged();
        }
    }

    private string description;

    public string Description
    {
        get { return description; }
        set
        {
            description = value; OnPropertyChanged();
        }
    }

    private string calculationDescription;

    public string CalculationDescription
    {
        get { return calculationDescription; }
        set
        {
            calculationDescription = value; OnPropertyChanged();
        }
    }

    private DateTime inactiveDate;

    public DateTime InactiveDate
    {
        get { return inactiveDate; }
        set
        {
            inactiveDate = value; OnPropertyChanged();
        }
    }

    public string ModifiedUser
    {
        get
        {
            return this.modifiedUser;
        }
        set
        {
            this.modifiedUser = value;
            OnPropertyChanged();
        }
    }

}

这工作得很好,除了Frequency财产。我怎样才能让它正常工作。我必须使用Enum类似这篇文章吗?XAML 中的数据表单 如果是这样,我将如何链接两者?

4

1 回答 1

0

我猜你想要的是 1 个具有许多 FrequencyChoices 关系的频率图

第一个我会将属性更改为从 PropertyChangedBase 继承

 public class FrequencyChoice : PropertyChangedBase
 {
 }

然后如下更改您的属性

 private BindableCollection<FrequencyChoice> frequencyChoices;
    public BindableCollection<FrequencyChoice> FrequencyChoices
    {
        get
        {
            return this.frequencyChoices;
        }
        set
        {
            if (Equals(value, this.frequencyChoices))
            {
                return;
            }
            this.frequencyChoices = value;
            this.NotifyOfPropertyChange(() => this.FrequencyChoices);
        }
    }

我不太确定 BindableBase 是什么(来自谷歌的是 Prism,但嘿,你使用 Caliburn,所以使用 PropertyChangedBase),但如果想继续使用它,请确保它为你处理更改通知

因为每张地图都有很多选择,您需要收集来存储选择

于 2014-08-18T09:11:02.923 回答