Home Forums WPF controls Xceed DataGrid for WPF Datagrid Binding (case 107495)

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

    Hi, I am trying to create a WPF app which has windows1.xaml. I have placed a xceed data grid control on it. I am able to bind using static source which comes from app.xaml file datatable. However, I wanted to bind this datagrid to the datatable which doesn’t come from app.xaml or which comes from data access layer instead. I have question about line in bold which says staticResource. I wanted to bind this datagrid to some business object. Otherwise, it looks like the datatable has to come from app.xaml file only and the data table will be loaded once the application is loaded (which is what I want to avoid).

    Please shed some light

    Here is my xml code.

    <Grid xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid”&gt;


    <xcdg:DataGridCollectionViewSource x:Key=”detailDataStore”

    Source=”{Binding Source={x:Static Application.Current},



    <xcdg:DataGridControl x:Name=”OrdersGrid”

    ItemsSource=”{Binding Source={StaticResource detailDataStore}}”/>


    Here is my app.xaml.cs class which loads the datatable detailData. I wanted to separate the data access from here to some data access layer. I do have one one but if I try to call the method from App() method it says need reference to the object even though I have a reference to the data access object dll. It looks like one can not call the method from a static method?

    public partial class App : System.Windows.Application


    private static DataTable detailData;

    IntranetReportsDAO.IntranetReportsDAO dao = new IntranetReportsDAO.IntranetReportsDAO();

    static App()


    int clientId = 1;

    DateTime startDate = new DateTime(2007, 3, 1);

    DateTime endDate = new DateTime(2007, 5, 1);

    DataTable myDetailData = new DataTable();

    string connectionString = “my connection string”;

    SqlConnection connection = new SqlConnection(connectionString);

    string procedure = “my procedure”;

    SqlCommand detailSqlCommand = new SqlCommand(procedure, connection);

    detailSqlCommand.CommandType = CommandType.StoredProcedure;

    detailSqlCommand.CommandText = procedure;

    SqlParameter date1Parameter = new SqlParameter(“@Date1”, startDate);

    SqlParameter date2Parameter = new SqlParameter(“@Date2”, endDate);

    SqlParameter idParameter = new SqlParameter(“@Id”, clientId);

    detailSqlCommand.Parameters.Add(date1Parameter );



    SqlDataAdapter dataAdapter = new SqlDataAdapter(detailSqlCommand);

    detailSqlCommand.CommandTimeout = 1000;




    detailData = myDetailData;


    public static DataTable DetailData




    return detailData;



    Imported from legacy forums. Posted by bemahesh (had 2057 views)

    User (Old forums)
    Post count: 23064

    I didnt go through your code but
    Why not set the ItemsSource in C# code behind when the window is created?
    then you can create your data object when the window is created too and not have to load it when the app starts (good if you app has multiple windows)


    grid.ItemsSource = MyData;

    Imported from legacy forums. Posted by MiddleTommy (had 2879 views)

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