c# - Datagrid not updating when query is fired -


so have datagrid in usercontrol. databound observable collection in viewmodel. viewmodel implements inotifypropertychanged interface , has been appropriately wired in view.

in view:

<datagrid autogeneratecolumns="false"           enablerowvirtualization="true"           itemssource="{binding contributioncollection, mode=twoway, updatesourcetrigger=propertychanged}">  <!-- datagrid rows -->  /> 

and in viewmodel:

    private observablecollection<contribution> _contributioncollection;     public observablecollection<contribution> contributioncollection     {                 {             return _contributioncollection;         }         set         {             _contributioncollection= value;             onpropertychanged("contributioncollection");         }     } 

what meant happen, that; @ click of specific button, query fires against database , brings results. results meant shown in datagrid.

    // fired icommand property     public object contributions_commandexecute(object param)                                                {         var querycontributions = context.contributions.where(c => c.member == member);         return _contributioncollection = new observablecollection<contribution>(querycontributions);     } 

but datagrid comes empty. application freezes bit, suggesting happening in background, nothing conveyed on view. in fact, time works properly, if viewmodel constructor fires query upon initialization. after that, won't fire again.

any idea i'm going wrong?

this line

return _contributioncollection = new observablecollection<contribution>(querycontributions); 

updates value of field. since doesn't use property setter, onpropertychanged("contributioncollection"); not called

the solution work property (by way, why method not void?)

// fired icommand property public void contributions_commandexecute(object param) {     var querycontributions = context.contributions.where(c => c.member == member);     contributioncollection = new observablecollection<contribution>(querycontributions); } 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -