Home Forums WPF controls Xceed DataGrid for WPF Grid empty after TabControl switch (bug?)

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

    Hi all,

    I have a WPF form with a TabControl on it. This TabControl contains two TabItems, on one of them is a DataGridControl. To this DataGridControl, a DataTable is bound via the ItemsSource property.

    Now if i switch to the second TabItem, and then back to the first with the DataGridControl, and do an Items.Refresh(), the Grid becomes empty.
    The GridControl.Items collection still contains the items/rows, but the grid doesnt display them.
    Am I doing something wrong or is this a bug?

    Thanks for answers

    Imported from legacy forums. Posted by Benno (had 33791 views)

    User (Old forums)
    Member
    Post count: 23064

    and another problem I discovered right now:

    If i make changes to the DataTable which is bound to the DataGridControl, the DataGrid isnt updated at all.
    I also discovered that the DataGrid is then updated if for example the column order is changed.

    Imported from legacy forums. Posted by Benno (had 12247 views)

    User (Old forums)
    Member
    Post count: 23064

    I actually have the same set up; a DataGridControl in a TabItem.

    OnLoad (Loaded event) I refresh the grid and re-set ItemSource. My grid is fine, and doesnt “become empty”.

    Check out these two functions in the DataBinding sample;

    private void ResetGrid(bool showInsertionRow, bool showGroupByControl)
    private void AdjustHeadersFooters(bool showInsertionRow, bool showGroupByControl)

    However, there is a different problem. I’ve not asked questions here about it yet, as I’m trying to work it out myself. Still, a warning – after switching back to the TabItem I lose the ability to SORT the grid. Doing so makes the grid ’empty’, and I assume it’s the same ’empty’ that you describe. I can sort the first time I view the grid.

    Imported from legacy forums. Posted by Jack (had 358 views)

    User (Old forums)
    Member
    Post count: 23064

    Seems like our problems are related to eachother
    Ive tried this ResetGrid() function.. i call it each time i switch back to the DataGridControl TabItem, and this seems to work better
    But is the call to this function really necessary?

    To your problem, im also unable to sort the grid after tabitem change, im also unable to GROUP the grid after this change ..

    Imported from legacy forums. Posted by Benno (had 288 views)

    User (Old forums)
    Member
    Post count: 23064

    Seems like the grid doesnt work correct at all if used in connection with TabItems .. is that confirmed by the staff?

    Imported from legacy forums. Posted by Benno (had 484 views)

    Xceed Support
    Member
    Post count: 5658

    I have tested out the scenario you are describing; however, the issues you are reporting are not occurring. Regardless of the state of the grid (e.g., sorted, grouped) when I switch to a another tab, the tab that contains the grid still shows the grid and its content, and the grid is still in the same state as it was when the second tab was pressed.

    Here is the code that I used:

    <code>
    TabControl tabControl = new TabControl();
    TabItem tab1 = new TabItem();
    TabItem tab2 = new TabItem();

    DataGridControl grid = new DataGridControl();
    DataGridCollectionView view = new DataGridCollectionView( App.Orders.DefaultView );
    grid.ItemsSource = view;

    tab1.Content = grid;
    tab2.Content = new Button();

    tabControl.Items.Add( tab1 );
    tabControl.Items.Add( tab2 );

    this.Content = tabControl;
    </code>

    Of course, I am using my own build of the assembly. Does the above code produce the same results with your version of the assembly? If so, please let me know what the assembly version is. If not, provide me with a quick snippet of your code that reproduces the issue and I will test again.

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

    User (Old forums)
    Member
    Post count: 23064

    thanks jenny for you reply 🙂

    ive also written the simplest possible example to test this, and yes it did produce the same results:

    xaml:

    <TabControl>
    <TabItem Header=”Tab1″>
    <xcdg:DataGridControl Name=”Grid1″/>
    </TabItem>
    <TabItem Header=”Tab2″/>
    </TabControl>

    codebehind:

    DataSet testDS = new DataSet();

    public Window1() {

    InitializeComponent();
    FillDS(); // << this fills the “testDS” DataSet from a SQL-Table, nothing special
    DataGridCollectionView dgcv = new DataGridCollectionView(testDS.Tables[0].DefaultView);
    Grid1.ItemsSource = dgcv;

    }

    now, as long as im on the first tab-page, everything works just fine, but if i switch to tab2 and back, i encounter the following problems:
    – sorting a column “clears” the grid (rows disappear)
    – grouping throws ArgumentOutOfRange exception
    – Grid1.Items.Refresh() also causes all items to disappear
    – the grid isnt updated correctly according to changes made to the dataset

    due to the fact that in your sample everything works fine, is it possible that it has something to do with my datasource or dataset? even if i cant imagine that ..

    thanks for your help

    Imported from legacy forums. Posted by Benno (had 447 views)

    Xceed Support
    Member
    Post count: 5658

    I tried the XAML/code combination you are using and it still works. The only difference I can see is that you are filling your dataset in code while mine is filled in the App.xaml.cs file and the DataTable is exposed as a property.

    I don’t think the datasource would cause this kind of issue but just in case: I am using the Orders table from the Access version of the Northwind database which is included in a Data folder as a resource in my project.

    What is the exact version of the assembly you are using? Have you installed the service release?

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

    User (Old forums)
    Member
    Post count: 23064

    Hmm .. thats really wired

    my version is: 1.1.7264.16200, and no, i didnt install a service release i think. Where can i get this release?

    Imported from legacy forums. Posted by Benno (had 503 views)

    Xceed Support
    Member
    Post count: 5658

    I am using a 1.2 version, which (in theory) should have no impact. You can download the service release <a href=”http://xceed.com/pages/TopMenu/Downloads/Updates.aspx?Lang=EN-CA”>here</a&gt;.

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

    Xceed Support
    Member
    Post count: 5658

    I just checked the release notes:

    “The DataGridControl can now be removed from and then added back to a VisualTree.”

    This should (don’t hold me to it!) solve the problem.

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

    User (Old forums)
    Member
    Post count: 23064

    Okay that sounds suspicious, thank you 🙂

    Ill give it a try and then post if it solved my problem

    Imported from legacy forums. Posted by Benno (had 422 views)

    User (Old forums)
    Member
    Post count: 23064

    I’ve post a simalur problem on the forum but nobody replied it yet. <a href=”http://forums.xceed.com/forums/ShowPost.aspx?PostID=7789″>Here</a&gt;

    Until I read this thread, I didn’t know the datagrid in the TabControl had a bug. On my post all of the code is in the TabControl.(Didn’t mention it on the post)

    Imported from legacy forums. Posted by JunHeeLee (had 833 views)

    User (Old forums)
    Member
    Post count: 23064

    Do we REALLY have to download a 72mb package just to get 2 dlls?

    Imported from legacy forums. Posted by Jack (had 911 views)

    User (Old forums)
    Member
    Post count: 23064

    actually, I can’t find version 1.2 by following that link. Jenny, could you please help me find it?

    Imported from legacy forums. Posted by Jack (had 298 views)

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