/// <summary> /// Binds <see cref="DataPresenter"/> to <see cref="CheckBox"/> to select/deselect all rows. /// </summary> /// <param name="dataPresenter">The <see cref="DataPresenter"/></param> /// <returns>The scalar binding object.</returns> public static ScalarBinding <CheckBox> BindToCheckBox(this DataPresenter dataPresenter) { return(ToSelectAll <CheckBox>(dataPresenter)); }
private bool ConfirmEndEdit() { return(DataPresenter == null ? true : DataPresenter.ConfirmEndEdit()); }
public void Initialize(DataPresenter dataPresenter) { DataPresenter = dataPresenter; }
private static ScalarBinding <T> ToSelectAll <T>(this DataPresenter dataPresenter) where T : ToggleButton, new() { if (dataPresenter == null) { throw new ArgumentNullException(nameof(dataPresenter)); } var trigger = new PropertyChangedTrigger <T>(ToggleButton.IsCheckedProperty).WithAction(v => { var binding = (TwoWayBinding)v.GetBinding(); if (binding.IsRefreshing) { return; } var isChecked = v.IsChecked; if (!isChecked.HasValue) { return; } var isSelected = isChecked.GetValueOrDefault(); var rows = dataPresenter.Rows; bool anyChange = false; for (int i = 0; i < rows.Count; i++) { var row = rows[i]; var oldValue = row.IsSelected; row.IsSelected = isSelected; if (row.IsSelected != oldValue) { anyChange = true; } } if (!anyChange) { dataPresenter.InvalidateView(); } }); return(new ScalarBinding <T>(onRefresh: v => { var selectedCount = dataPresenter.SelectedRows.Count; if (selectedCount == 0) { v.IsChecked = false; } else if (selectedCount == dataPresenter.Rows.Count - (dataPresenter.VirtualRow != null ? 1 : 0)) { v.IsChecked = true; } else { v.IsChecked = null; } }, onSetup: v => { trigger.Attach(v); }, onCleanup: v => { trigger.Detach(v); })); }
/// <summary> /// Binds <see cref="DataPresenter"/> to <see cref="GridHeader"/> to select/deselect all rows. /// </summary> /// <param name="dataPresenter">The DataPresenter.</param> /// <returns>The scalar binding object.</returns> public static ScalarBinding <GridHeader> BindToGridHeader(this DataPresenter dataPresenter) { return(ToSelectAll <GridHeader>(dataPresenter)); }
void IService.Initialize(DataPresenter dataPresenter) { throw new NotSupportedException(); }
public DataLoader(DataPresenter <T> dataPresenter) { Debug.Assert(dataPresenter != null); _dataPresenter = dataPresenter; }