wpf - Why does my DataGrid populate only after scrolling in and out of view? -


i have wpf datagrid itemssource bound observablecollection>.

tuple simple class made stores 4 strings in array. here generic version:

public class tuple<t>: inotifypropertychanged     {         private int _size = 0;          public tuple(int size)         {             this._size = size;             _objs = new t[_size];         }          private t[] _objs;          public t this[int i]         {                         {                 return _objs[i];             }             set             {                 _objs[i] = value;                 onpropertychanged(".[" + + "]");             }         }          public void onpropertychanged(string name)         {             propertychangedeventhandler handler = propertychanged;             if (handler != null)             {                 handler(this, new propertychangedeventargs(name));             }         }          public event propertychangedeventhandler propertychanged;     } 

at compile time know have 4 columns , bind them index of tuple. @ runtime, tuples added observablecollection , modified. however, running problem datagrid updates when tuple created... output looks this:

enter image description here

the data present in observablecollection, if scroll datagrid in , out of view, text inside cells appears:

enter image description here

any tips?

your tuple updates when it's created don't notify index changed whole indexer property has changed:

public t this[int i] {    { return _objs[i]; }    set    {        _objs[i] = value;        onpropertychanged(binding.indexername);    } } 

as second part text appears when comes view it's due virtualizingstackpanel default true , means items not in view not rendered , bindings not evaluated until in view again


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -