示例#1
0
        private void SetDefaultValues()
        {
            ItemsSource = new ObservableCollection <object>();

            PageSizes.Clear();
            PageSizes.Add(10);
            PageSizes.Add(20);
            PageSizes.Add(50);
            PageSizes.Add(100);

            cmbPageSizes.IsEditable    = false;
            cmbPageSizes.SelectedIndex = 0;
        }
示例#2
0
        private void BindProperties()
        {
            if (!IsPagingEnable)
            {
                return;
            }
            Binding propBinding;

            propBinding = new Binding(nameof(Page));
            propBinding.RelativeSource      = new RelativeSource(RelativeSourceMode.TemplatedParent);
            propBinding.Mode                = BindingMode.TwoWay;
            propBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            txtPage.SetBinding(TextBox.TextProperty, propBinding);

            //cmbPageSizes.ItemsSource = null;
            List <int> ps = PageSizes.Distinct().ToList();

            PageSizes.Clear();
            ps.ForEach((i) => { PageSizes.Add(i); });
            propBinding = new Binding(nameof(PageSizes));
            propBinding.RelativeSource      = new RelativeSource(RelativeSourceMode.TemplatedParent);
            propBinding.Mode                = BindingMode.OneTime;
            propBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            cmbPageSizes.SetBinding(ComboBox.ItemsSourceProperty, propBinding);
            //cmbPageSizes.ItemsSource = new ObservableCollection<int>() {10,50,100,150,200,500,1000};

            propBinding = new Binding(nameof(TotalPages));
            propBinding.RelativeSource      = new RelativeSource(RelativeSourceMode.TemplatedParent);
            propBinding.Mode                = BindingMode.TwoWay;
            propBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            txtTotalPage.SetBinding(TextBox.TextProperty, propBinding);

            propBinding = new Binding(nameof(ItemsData));
            propBinding.RelativeSource      = new RelativeSource(RelativeSourceMode.Self);
            propBinding.Mode                = BindingMode.TwoWay;
            propBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            SetBinding(ItemsSourceProperty, propBinding);
        }