Adding a range of values to an ObservableCollection efficiently

前端 未结 4 1279
Happy的楠姐
Happy的楠姐 2020-12-24 06:29

I have an ObservableCollection of items that is bound to a list control in my view.

I have a situation where I need to add a chunk of values to the star

4条回答
  •  Happy的楠姐
    2020-12-24 07:07

    Example: Desired steps 0,10,20,30,40,50,60,70,80,90,100 --> min=0, max=100, steps=11

        static int min = 0;
        static int max = 100;
        static int steps = 11; 
    
        private ObservableCollection restartDelayTimeList = new ObservableCollection (
            Enumerable.Range(0, steps).Select(l1 => (min + (max - min) * ((double)l1 / (steps - 1))).ToString())
        );
    

提交回复
热议问题