I hope someone can tell me the reason for this behaviour:
If I do the following:
<DataGrid ItemsSource="{Binding Model.Bytes}" .../>
My ViewModel constructor:
public ViewModel()
{
Model = new Message();
Model.Bytes.Add(new Byte(){Range = "42"});
}
Nothing happens and the output window doesn't show any errors.
But If I wrap this Byte collection:
public ICollection<Byte> Bytes
{
get { return Model.Bytes; }
set
{
Model.Bytes = value;
RaisePropertyChanged(()=> Bytes);
}
}
And write:
<DataGrid ItemsSource="{Binding Bytes}".../>
The datagrid shows the entry and I can add new ones.
My Message-Class
public Message()
{
Bytes = new ObservableCollection<Byte>();
}
public virtual ICollection<Byte> Bytes
{
get { return GetValue(() => Bytes); }
set { SetValue(() => Bytes, value); }
}
I think it is a notification problem, but I don't know where or why...
Thank you in advance
<DataGrid ItemsSource="{Binding Model.Bytes}" .../>
this means your DataContext have to be an object with a PUBLIC property MODEL, and the type of this property must have a PUBLIC property Bytes. if this is the case, then it just seems to be a notification problem.
simply check your DataContext and Binding at runtime with Snoop.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.