我有一個類,從BindableBase,其中包含兩個屬性得出:XAML GridView控件,並的ObservableCollection改變項目的屬性
private string sourceCallNumber;
public string SourceCallNumber
{
get { return sourceCallNumber; }
set { SetProperty(ref sourceCallNumber, value); }
}
private string sourceMediaType;
public string SourceMediaType
{
get { return sourceMediaType; }
set { SetProperty(ref sourceMediaType, value); }
}
我有一個包含一些使用類項目的一個ObservableCollection。
我有一個GridView爲其設置ItemsSource指向ObservableCollection。
我的問題是,如果我改變的,比如說,SourceMediaType上的項目的一個值,顯示不更新。我已經把調試,並可以確認更改值導致OnPropertyChanged觸發該屬性。
我讀過周圍類似的問題相當多的SO問題和答案,我得到的是什麼,我需要爲了得到這個工作做的相當困惑。
我的理解是,雖然本身的ObservableCollection當一個屬性更改不會做任何事情,如果項目本身觸發OnPropertyChanged,應該得到更新顯示。
(我讀到的一個答案提出使用提供的代碼叫做TrulyObservableCollection,但是我得到的問題是所有內容都刷新了,而不僅僅是一個已更新的項目)。
請問我有什麼遺漏或誤解?
謝謝。
你解釋的方式沒有錯。你確定綁定不是一次性嗎?你可以添加Xaml代碼嗎? – Reza
我會在這裏進行一次瘋狂的嘗試,在你的SetProperty函數中,你不應該傳遞一個字符串來代表被更改的實際屬性嗎?除非你從字段名稱中獲得屬性名稱(這將需要所有的都遵循相同的模式)。 –
@Reza - 不,綁定不是OneTime。 –