Avalonia
Avalonia copied to clipboard
ObservableCollection.Add for DataGrid
Describe the bug ObservableCollection.Add for DataGrid,Do not refresh
My Code:
1、
<Grid ColumnDefinitions="*,*"> <ListBox Grid.Column="0" Items="{Binding BindGdList}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding queueno}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <DataGrid Grid.Column="1" Items="{Binding BindGdList}" > <DataGrid.Columns> <DataGridTextColumn Binding="{Binding queueno}" Header="No." Width="100"/> <DataGridTextColumn Binding="{Binding szzname}" Header="Name" Width="100"/> </DataGrid.Columns> </DataGrid> </Grid>
2、BindGdList is ObservableCollection
3、 When I Change BindGdList Add One Element,as BindGdList.Add(model);
4、DataGrid cannot display the newly added data,but ListBox can.
5、This Code is not problem in Version 0.10.18
- OS: [Windows]
- Version [11.0]
probably duplicate with https://github.com/AvaloniaUI/Avalonia/issues/8970
probably duplicate with #8970
Version 0.10.18 is OK Version 11.0.0 has a problem
Please, update issue with more detailed description and add steps to reproduce or even better a minimal project where it can be reproduced.
Please, update issue with more detailed description and add steps to reproduce or even better a minimal project where it can be reproduced. My Code: 1、
<Grid ColumnDefinitions="*,*"> <ListBox Grid.Column="0" Items="{Binding BindGdList}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding queueno}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <DataGrid Grid.Column="1" Items="{Binding BindGdList}" > <DataGrid.Columns> <DataGridTextColumn Binding="{Binding queueno}" Header="No." Width="100"/> <DataGridTextColumn Binding="{Binding szzname}" Header="Name" Width="100"/> </DataGrid.Columns> </DataGrid> </Grid>
2、BindGdList is ObservableCollection 3、 When I Change BindGdList Add One Element,as BindGdList.Add(model); 4、DataGrid cannot display the newly added data,but ListBox can. 5、This Code is not problem in Version 0.10.18
@duxunmi can you attach an archive with project that can be reproduced?
I tried your XAML code, and it works as expected:
@duxunmi can you attach an archive with project that can be reproduced? I tried your XAML code, and it works as expected: ![image](https://user-images.githubusercontent.com/3163374/195778487-bf9a27c6-9b99-4501-ad27-5a99b873da80.png
Now I find that when the dataGrid is not activated, there will be a problem You demo need add a tabControl ,when switch to another tabitem,the problem has happend.