Home Forums WPF controls Xceed DataGrid for WPF Binding datagrid to a list of objects

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

    Can I call a method that returns a list of objects and then display the screen that holds the datagrid and populate the datagrid with that list of objects?

    example.

    public void ShowCustomers()
    {
    <List>Customer customers = Customer.GetCustomers();
    CustomerUC custUC = new CustomerUC();
    mainWindow.contentPanel.children.Add(custUC);
    }

    I would like to bind the grid on the user control CustomerUC to the list collection customers. Is that possible?

    Bill

    Imported from legacy forums. Posted by Bill (had 467 views)

    User (Old forums)
    Member
    Post count: 23064

    there are many ways you could do this.
    one easy way is:
    You could add a property to your UserControl that sets the IEnumerable source of the grid.

    public IEnumerable GridSource
    {
    set{ YourGridControl.ItemsSource = value;}

    }

    …..

    //then in your ShowCustomers method
    public void ShowCustomers()
    {
    <List>Customer customers = Customer.GetCustomers();
    CustomerUC custUC = new CustomerUC();
    custUC.GridSource = customers;
    mainWindow.contentPanel.children.Add(custUC);
    }

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

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