Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

ObservableCollection.Add for DataGrid

Open duxunmi opened this issue 1 year ago • 6 comments

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]

duxunmi avatar Oct 08 '22 06:10 duxunmi

probably duplicate with https://github.com/AvaloniaUI/Avalonia/issues/8970

rabbitism avatar Oct 08 '22 14:10 rabbitism

probably duplicate with #8970

Version 0.10.18 is OK Version 11.0.0 has a problem

duxunmi avatar Oct 09 '22 03:10 duxunmi

Please, update issue with more detailed description and add steps to reproduce or even better a minimal project where it can be reproduced.

maxkatz6 avatar Oct 09 '22 05:10 maxkatz6

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 avatar Oct 09 '22 09:10 duxunmi

@duxunmi can you attach an archive with project that can be reproduced? I tried your XAML code, and it works as expected: image

maxkatz6 avatar Oct 14 '22 06:10 maxkatz6

@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.

图片

duxunmi avatar Oct 14 '22 07:10 duxunmi