Home Forums WPF controls Xceed DataGrid for WPF Help with First Grid

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #26416 |


    I’m having trouble binding my dataTable to the grid. This is my first attempt. I’ve read the examples but I’m not sure why it doesn’t work. The grid displays with the column name but no data. I’ve tested the routine and Stored Proc to make sure they are working properly and returning data.

    Here’s part of the code behind:

    private static System.Data.DataTable _ActionTable;
    public System.Data.DataTable ActionTable
    get { return _ActionTable; }
    set { _ActionTable = value; }

    private void PopulateGrid()
    RPOBusTier.Actions acts = new RPOBusTier.Actions();

    this.ActionTable = acts.LoadGrid(“”, “”, “Action”, System.Convert.ToInt32(‘0’), “Y”);

    if (acts != null)

    I’ve checked and ActionTable does contain data.

    The XAML:
    <Grid Grid.Row=”2″ xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid”&gt;
    <xcdg:DataGridCollectionViewSource x:Key=”ActionGrid”
    Source=”{Binding Source={x:Static Application.Current},

    <my:DataGridControl Margin=”143,42,155,54″ Name=”dataGridControl1″
    ItemsSource=”{Binding Source={StaticResource ActionGrid}}”
    xmlns:my=”clr-namespace:Xceed.Wpf.DataGrid;assembly=Xceed.Wpf.DataGrid” Grid.Row=”2″>
    <xcdg:Column FieldName=”WoNumber” Title=”WO#” Width=”100″ />
    <xcdg:ZuneNormalColorTheme />

    I’m just not sure were the error is located.

    Thanks for your help.
    Dale Williams

    Imported from legacy forums. Posted by Dale (had 1713 views)

    Xceed Support
    Post count: 5658

    Your code assumes that the ActionTable property is static and located in the app.xaml.cs file. However, your code states that the ActionTable property is not static and I will assume not located in the Application code-behind file. That said, you will need to change the binding in order for the grid to be populated with the data. The column appears because you are defining it in the grid’s Columns collection.

    If your ActionTable property is located in the MainWindow, your binding would look something like the following:

    <xcdg:DataGridCollectionViewSource x:Key=”ActionGrid”
    Source=”{Binding Source={RelativeSource AncestorType={x:Type local:MainWindow}}, Path=ActionTable}”/>

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

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