コード例 #1
0
        private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
        {
            if ((int)(e.VerticalOffset / (e.ExtentHeight - e.ViewportHeight) * 100) >= RatioTriggeringScroll)
            {
                if (Items.Count < Data.Count)
                {
                    int itemsCount = Items.Count;

                    for (int i = itemsCount; i < (itemsCount + MuchToOutput < Data.Count ? itemsCount + MuchToOutput : Data.Count); i++)
                    {
                        var checkBox = new CheckBoxForExpander();
                        checkBox.VerticalAlignment   = VerticalAlignment.Top;
                        checkBox.HorizontalAlignment = HorizontalAlignment.Left;
                        checkBox.Margin            = new Thickness(10, 10 + (i * 30), 0, 0);
                        checkBox.IsChecked         = ContainsValue(Data[i]);
                        checkBox.Data              = Data[i];
                        checkBox.DisplayMemberPath = DisplayMemberPath;
                        checkBox.SelectedValuePath = SelectedValuePath;
                        checkBox.CheckedChanged   += CheckBox_CheckedChanged;
                        Items.Add(checkBox);

                        RenderContorl(checkBox);
                    }
                }
            }
        }
コード例 #2
0
        private void GenerateItems()
        {
            Items.Clear();

            for (int i = 0; i < (Data.Count > StartupToOutput ? StartupToOutput : Data.Count); i++)
            {
                var checkBox = new CheckBoxForExpander();
                checkBox.VerticalAlignment   = VerticalAlignment.Top;
                checkBox.HorizontalAlignment = HorizontalAlignment.Left;
                checkBox.Margin            = new Thickness(10, 10 + (i * 30), 0, 0);
                checkBox.IsChecked         = ContainsValue(Data[i]);
                checkBox.Data              = Data[i];
                checkBox.DisplayMemberPath = DisplayMemberPath;
                checkBox.SelectedValuePath = SelectedValuePath;
                checkBox.CheckedChanged   += CheckBox_CheckedChanged;
                Items.Add(checkBox);
            }
        }