0
我想讓ListView更改爲我在ObvservableCollection中修改的任何值。UI不類似ObservableCollection
我目前使用這和收藏結合我的ListView
private ObservableCollection<Task> _tasks = TaskInit.TaskCollection;
/// <summary>
/// Observable Collection to hold all tasks
/// </summary>
///
public ObservableCollection<Task> TasksCollection
{
get { return _tasks; }
set
{
_tasks = value;
NotifyPropertyChanged("TasksCollection");
}
}
的問題是如果我是使用下面的代碼:
TaskInit.TasksCollection[2].TaskNumber = "hi";
值仍然是相同的如前所述,即使它應該改變。
任何人都可以指出我可能做的問題嗎?
的XAML的第一行是:
<ListView SelectionMode="Single" ScrollViewer.CanContentScroll="True" x:Name="listTasks" Margin="0,0,0,35" Background="{x:Null}" BorderBrush="{x:Null}" ItemsSource="{Binding TasksCollection, Mode=TwoWay}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" FontFamily="Myriad Pro" Foreground="{x:Null}" IsSynchronizedWithCurrentItem="True">
任務類別:
public class Task : INotifyPropertyChanged
{
/// <summary>
///
/// </summary>
public string Module { get; set; }
/// <summary>
///
/// </summary>
public string FirstValue { get; set; }
/// <summary>
///
/// </summary>
public string SecondValue { get; set; }
/// <summary>
///
/// </summary>
public string ThirdValue { get; set; }
/// <summary>
///
/// </summary>
public int Minutes { get; set; }
/// <summary>
///
/// </summary>
public string TaskNumber { get; set; }
/// <summary>
///
/// </summary>
public string Story1 { get; set; }
/// <summary>
///
/// </summary>
public string Story2 { get; set; }
/// <summary>
///
/// </summary>
public string Story3 { get; set; }
/// <summary>
///
/// </summary>
public string NetworkAdapter { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
對不起,我有點困惑,就在你展示的'public string task'部分。我用我的任務類更新了我的問題。 – 2012-08-09 22:07:25
看我的編輯。你的TaskNumber屬性應該看起來像這樣。 – 2012-08-09 22:10:39
完美工作,從來不知道這是一個簡單的修復。謝謝 – 2012-08-10 08:18:00