Home Forums WPF controls Xceed DataGrid for WPF Bug: Inserted items always end up last in the view

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25232 |

    Hi,

    Is this the right place to file bug reports?

    When I insert an item into an ObservableCollection the item ends up last in the view unless i fire a CollectionReset event.

    FireCollectionChanged(NotifyCollectionChangedAction.Add, item, index);

    with an index less than the size of the collection should properly redraw the view.

    Regards
    Anders

    Imported from legacy forums. Posted by Anders (had 3394 views)

    Xceed Support
    Member
    Post count: 5658

    Are you inserting the item in the collection programmatically or through the InsertionRow?

    If you are doing it programmatically, can you provide the code that is used to insert?

    If you are doing it through the InsertionRow, then it is not a bug, an item will always be added to the end of the list, unless a sort is present.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 331 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for the quick reply.

    I am inserting it programmatically. It seems it has to do with the CollectionView
    Quick extract of the code follows below.

    Anders

    <Window x:Class=”Evolver.wpf.Window1″
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:DataGrid=”clr-namespace:Xceed.Wpf.DataGrid;assembly=Xceed.Wpf.DataGrid”
    Title=”Window1″ Height=”300″ Width=”300″
    >
    <StackPanel>
    <DataGrid:DataGridControl x:Name=”grid” ItemsSource=”{Binding}”/>
    <Button Content=”InsertAt3″ Click=”button_Clicked”/>

    </StackPanel>
    </Window>

    using System.Collections.ObjectModel;
    using System.Windows;
    using Evolver.Model3.Util;
    using Xceed.Wpf.DataGrid;

    namespace Evolver.wpf
    {
    public partial class Window1 : Window
    {
    ObservableCollection<string> strings = new ObservableCollection<string>();
    private int i = 0;

    public Window1()
    {
    InitializeComponent();
    for (int i = 0; i < 5; i++)
    strings.Add(“Tapir_” + i);
    DataGridCollectionView v = new DataGridCollectionView(strings, typeof (string));

    grid.ItemsSource = v;
    }

    private void button_Clicked(object sender, RoutedEventArgs args)
    {
    strings.Insert(3, “Tapir_new” + i++);
    }
    }
    }

    Imported from legacy forums. Posted by Anders (had 372 views)

    Xceed Support
    Member
    Post count: 5658

    Thank you for bringing this to our attention. I have confirmed this to be an issue with the DataGridCollectionView, which will be corrected (it is too late for the upcoming version so it will either be a hotfix or available in the version after the upcoming one).

    In the meantime, other than refreshing the DataGridCollectionView, there is no solution.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 356 views)

    User (Old forums)
    Member
    Post count: 23064

    You can obtain the fix (latest package) <a href=”http://download3.xceedsoft.com/Packages/3.2.7559.11410/XceedComponents.exe “>
    here</a>

    Imported from legacy forums. Posted by Matt (had 4524 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.