Привязка UltraTree к отображаемому тексту бизнес-объекта - PullRequest
0 голосов
/ 06 марта 2012

Я привязываю элемент управления UltraTree (версия 10.3) к пользовательскому источнику данных, например:

public void Populate(List<FilterDimension> data)
{
    DataBindings.Clear();
    DataSource = data;
    Nodes[0].DataColumnSetResolved.NodeTextColumn = Nodes[0].DataColumnSetResolved.Columns["DisplayText"];
}

Я ожидаю, что изменение свойства DisplayText для любого из связанных FilterDimension объектов приведет к обновлению текста узла UltraTree. В действительности, текст в дереве не обновляется, и событие PropertyChanged остается null, указывая, что UltraTree даже не прослушивает это уведомление. Как заставить UltraTree прослушивать изменения свойств в FilterDimension?

Вот соответствующий код от FilterDimension:

internal class FilterDimension : INotifyPropertyChanged
{
    private string _displayText = null;
    private string _name = null;

    private BindingList<string> _values = new BindingList<string>();

    /// <summary>
    /// Gets or sets the display friendly name.
    /// </summary>
    public string Name
    {
        get { return _name; }
        set
        {
            _name = value;
            FirePropertyChangedNotification("Name");
            if (_displayText == null) { FirePropertyChangedNotification("DisplayText"); }
        }
    }

    /// <summary>
    /// Gets or sets the display text that is used in TreeView nodes.  When null, uses the Name.
    /// </summary>
    public string DisplayText
    {
        get { return _displayText ?? Name; }
        set { _displayText = value; FirePropertyChangedNotification("DisplayText"); }
    }

    /// <summary>
    /// Gets a read/write list of values.  Is never null.
    /// </summary>
    public BindingList<string> Values
    {
        get { return _values; }
        set { _values = value ?? new BindingList<string>(); }
    }

    #region Events

    public event PropertyChangedEventHandler PropertyChanged;

    protected void FirePropertyChangedNotification(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    #endregion
}

1 Ответ

1 голос
/ 06 марта 2012

Оказывается, все, что мне нужно было сделать, это изменить на BindingList<FilterDimension> вместо List<FilterDimension ... Я полностью упустил, что элемент управления ожидает всплывающих уведомлений из списка.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...