Home Forums WPF controls Xceed DataGrid for WPF Why App.xaml.cs?

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

    Hi all,

    I’ve just downloaded the Xceed datagrid for WPF and tried out the first
    example (binding the grid to the Northwind orders table).

    I would like to know if there is a special reason why I have to put the code
    in App.xaml.cs?
    I want to use this grid in a larger project and would like to keep the XAML- and
    the C#-code together. If I create a new WPF window (named Window1 by default),
    I would like to put all related C# code in Window1.xaml.cs.
    Is there a way to do this?
    If not, I cannot really use this control.

    BTW, scrolling through the Orders table is terribly slow.
    Is there a way to speed things up?

    Thanks for your answer,
    Michael Nicolai-Deutschmann.

    (I cannot search this forum. Whenever I click on “GO”, I get a 404). 🙁

    Imported from legacy forums. Posted by Michael (had 933 views)

    Xceed Support
    Member
    Post count: 5658

    In our samples, the code in the App.xaml.cs is used soley to get the data we are using in the sample. You can place the code anywhere you like, including Window1.

    When a grid is slow, it usually indicates that virtualization is not being used. Is it possible that the grid is contained in a StackPanel?

    The search problem is a known issue that will be corrected with the next version of the forums. For the moment, use the Search option on the main forum page.

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

    User (Old forums)
    Member
    Post count: 23064

    Hi Jenny,

    thanks for yur reply.

    > In our samples, the code in the App.xaml.cs is used soley to get the data
    > we are using in the sample.
    > You can place the code anywhere you like, including Window1.

    Of course I tried to put the example code in Window1, but I always got an
    emtpy grid.
    Perhaps I have to change the binding? I’m fairly new to WPF.
    How do I have to change the binding to work for Window1?
    “Application.Current” does not seem to be correct.
    Even “{Binding Path=Orders,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type local:Window1}}}” does not work.
    (xmlns:local=”clr-namespace:WindowsApplication1″)

    Could you please give me a hint on how to get this working?

    > When a grid is slow, it usually indicates that virtualization is not being used.
    > Is it possible that the grid is contained in a StackPanel?

    No, I do not use a stackpanel. I created a new WPF window application and copied
    the example source code into it.
    The Orders table only has 830 rows. Do I really have to use virtualization with these
    few data?

    If these questions have already been answered, please give me a hint (url?) where
    to look.

    Thanks,
    Michael Nicolai-Deutschmann.

    Imported from legacy forums. Posted by Michael (had 650 views)

    User (Old forums)
    Member
    Post count: 23064

    Ok, I’ve got the empty grid problem solved.

    When using code in Window1.xaml.cs you have to set the ItemsSource by code:

    “OrdersGrid.ItemsSource = Orders.DefaultView;”

    The binding in XAML does not seem to work if the code is not in App.xaml.cs??????

    But, even if I restrain the Height and Width as proposed in the docu, displaying
    only 830 rows of data is slow. I would expect this behaviour with 100000+ rows,
    but not with only 830.
    But perhaps I’m doing something wrong?

    <xcdg:DataGridControl Height=”400″ Width=”400″ MaxHeight=”400″ MaxWidth=”400″ x:Name=”OrdersGrid” />

    Have a nice day,
    Michael Nicolai-Deutschmann

    Imported from legacy forums. Posted by Michael (had 533 views)

    User (Old forums)
    Member
    Post count: 23064

    Michael,

    Thanks for that tip!

    I have wasted all day trying to get the sample code working. I was just about to uninstall this Xceed stuff in disgust…if the first sample does not work is there any hope?

    Hopefully I can make some progress now!

    Is there a sample that shows how to add data from c#?

    I’m also new to WPF and find the binding syntax utterly confusing (I know that’s not an Xceed thing)

    Andrew

    Imported from legacy forums. Posted by Andrew (had 486 views)

    Xceed Support
    Member
    Post count: 5658

    “The binding in XAML does not seem to work if the code is not in App.xaml.cs?????? “

    No. Binding the ItemsSource property will work in any location as long as the source you are trying to bind to is an accessible scope.

    The ItemsSource property can be set by code or via XAML. The examples found in the documentation (and the installed samples) demonstrate how to do it in XAML. Some also show how it is done in code.

    As for speed, I will need to see more code, such as what element the grid is contained in and any other settings.

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

    Xceed Support
    Member
    Post count: 5658

    What was not working with the sample and which sample were you using?

    To add data to the grid programmatically, you can either do so directly through the grid’s Items property (it is an ItemsControl) or you can add items to the SourceItems property of the DataGridCollectionView, which can then be assigned as the grid’s ItemsSource.

    There are some examples in the documentation on how to use the SourceItems property in XAML.

    Binding can be daunting at first, but after the initial hurdle, you’ll start enjoying the possibilities it offers.

    If you find something with the product that is not working or that you need information or help on, let us know! We are here to help 🙂

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

    User (Old forums)
    Member
    Post count: 23064

    I am using VS 2008 Beta 2 and created an empty WPF application. I was attempting to paste the demo code into that empty application. I took the code from Getting Started>Installation Instructions from the help file. The confusion is caused by the fact that a VS2008 WPF application starts with a main window called Window1 not App.

    Andrew

    Imported from legacy forums. Posted by Andrew (had 462 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Andrew,

    Probably that these problems are caused by some incompatibilities introduced by the VS2008 Beta 2.

    Effectively, the .NET 3.5 beta introduced some changes in the .NET 3.0 DLLs…

    Those changes impact the way the DataGridCollectionView gets “detected” by the DataGridControl.

    To “workaround” this problem, you need to bind to:

    <DataGridControl ItemsSource=”{Binding Source={StaticResource xyz}, Path=View}” />

    The good news is: this workaround will also work on the original .NET 3.0 release.

    I have asked a forum moderator to add this information to a pinned post or to the readme post… I’m currently waiting for it to be created.

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

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