WPF ListBox, не обновляющий с ItemsSource

Устранение проблемы в ответе @adneal: если для setErrorEnabled не задано значение true, mErrorView будет иметь значение null, и если вы установите значение false в любой момент, шрифт изменится на значение по умолчанию. чтобы исправить это:

в вашем пользовательском переопределении TextInputLayout setErrorEnabled

@Override
public void setErrorEnabled(boolean enabled) {

    super.setErrorEnabled(enabled);

    if (enabled) {

        try {

            Field cthf = TextInputLayout.class.getDeclaredField("mErrorView");
            cthf.setAccessible(true);

            TextView error = (TextView) cthf.get(this);

            if (error != null)
                error.setTypeface(tf);


        } catch (Exception e) {

        }
    }
}
9
задан Dave Clemmer 2 August 2011 в 15:40
поделиться

2 ответа

Ваш m_VariableList реализует INotifyCollectionChanged ? Если это не ObservableCollection, то изменения его содержимого не будут автоматически отражаться в пользовательском интерфейсе.

19
ответ дан 4 December 2019 в 08:02
поделиться

The problem is not in the XAML that you have provided. I used the same XAML successfully in a test application; however, I was able to replicate the issue you are experiencing by re-instantiating the m_VariableList variable.

When the m_VariableList is given a new instance, or pointed to a new object, it is not reflected in the ListBox because the control has its own reference to the data. This may not be the cause of your problem, but I'd recommend looking over your code-behind to ensure that the variable is not getting re-instantiated.

8
ответ дан 4 December 2019 в 08:02
поделиться
Другие вопросы по тегам:

Похожие вопросы: