/// <summary> /// Gets the flushing error. /// </summary> /// <param name="rowPresenter">The row presenter.</param> /// <returns>The flushing error.</returns> public FlushingError GetFlushingError(RowPresenter rowPresenter) { RowBinding rowBinding = RowBinding; var element = rowBinding[rowPresenter]; return(element != null?GetFlushingError(element) : null); }
/// <summary> /// Binds <see cref="IColumns"/> to <see cref="ValidationPlaceholder"/>. /// </summary> /// <param name="source">The source <see cref="IColumns"/>.</param> /// <param name="bindings">The bindings to determine whether the <see cref="ValidationPlaceholder"/> is active.</param> /// <returns>The row binding object.</returns> public static RowBinding <ValidationPlaceholder> BindToValidationPlaceholder(this IColumns source, params RowBinding[] bindings) { source.VerifyNotNull(nameof(source)); source = source.Seal(); var result = new RowBinding <ValidationPlaceholder>(onSetup: (v, p) => { if (bindings != null && bindings.Length > 0) { var containingElements = new UIElement[bindings.Length]; for (int i = 0; i < containingElements.Length; i++) { containingElements[i] = bindings[i].GetSettingUpElement(); } v.Setup(containingElements); } }, onRefresh: null, onCleanup: (v, p) => { v.Cleanup(); }); var input = result.BeginInput(new ValueChangedTrigger <ValidationPlaceholder>(source, result)); foreach (var column in source) { input.WithFlush(column, (r, v) => true); } return(input.EndInput()); }
public void RowCompositeBinding_XAML() { var dataSet = DataSetMock.ProductCategories(1); var _ = dataSet._; RowBinding <Label> label = null; RowBinding <TextBlock> textBlock = null; RowCompositeBinding <XamlPane> pane = null; var elementManager = dataSet.CreateElementManager(builder => { textBlock = _.Name.BindToTextBlock(); label = _.Name.BindToLabel(textBlock); pane = new RowCompositeBinding <XamlPane>().AddChild(label, v => v.Label).AddChild(textBlock, v => v.TextBlock); builder.GridRows("100").GridColumns("100").AddBinding(0, 0, pane); }); Assert.IsNull(label.SettingUpElement); Assert.IsNull(textBlock.SettingUpElement); Assert.IsNull(pane.GetSettingUpElement()); var currentRow = elementManager.Rows[0]; Assert.AreEqual(pane[currentRow].Children[0], label[currentRow]); Assert.AreEqual(pane[currentRow].Children[1], textBlock[currentRow]); Assert.AreEqual(_.Name.DisplayName, label[currentRow].Content); Assert.AreEqual(currentRow.GetValue(_.Name), textBlock[currentRow].Text); Assert.AreEqual(textBlock[currentRow], label[currentRow].Target); }
internal void Refresh(T element, RowPresenter rowPresenter) { if (!IsFlushing && !IsLockedByFlushingError(element)) { RowBinding.Refresh(element, rowPresenter); } element.RefreshValidation(GetValidationInfo(rowPresenter)); }
/// <summary> /// Adds behavior to row binding. /// </summary> /// <typeparam name="T">Element type of row binding.</typeparam> /// <param name="rowBinding">The row binding.</param> /// <param name="behavior">The behavior.</param> /// <returns>The row binding for fluent coding.</returns> public static RowBinding <T> AddBehavior <T>(this RowBinding <T> rowBinding, IRowBindingBehavior <T> behavior) where T : UIElement, new() { if (behavior == null) { throw new ArgumentNullException(nameof(behavior)); } rowBinding.InternalAddBehavior(behavior); return(rowBinding); }
internal static void SetRowPresenter(this UIElement element, RowBinding rowBinding, RowPresenter value) { element.SetRowPresenter(value); var childBindings = rowBinding.ChildBindings; for (int i = 0; i < childBindings.Count; i++) { var childBinding = childBindings[i]; var childElement = rowBinding.GetChild(element, i); childElement.SetRowPresenter(childBinding, value); } }
/// <summary> /// Merges editor row binding into <see cref="InPlaceEditor"/>, with inert element displays as string. /// </summary> /// <typeparam name="T">The element type of the editor row binding.</typeparam> /// <param name="editorRowBinding">The editor row binding.</param> /// <param name="format">A composite format string.</param> /// <param name="formatProvider">An object that supplies culture-specific formatting information.</param> /// <returns>The row binding object of <see cref="InPlaceEditor"/>.</returns> public static RowBinding <InPlaceEditor> MergeIntoInPlaceEditor <T>(this RowBinding <T> editorRowBinding, string format = null, IFormatProvider formatProvider = null) where T : UIElement, new() { var rowInput = VerifyEditorBinding(editorRowBinding, nameof(editorRowBinding)); if (!(rowInput.Target is Column column)) { throw new ArgumentException(DiagnosticMessages.InPlaceEditor_EditorRowBindingNotColumn, nameof(rowInput)); } var inertRowBinding = column.BindToTextBlock(format, formatProvider); return(MergeIntoInPlaceEditor(rowInput, inertRowBinding)); }
private static RowInput <T> VerifyEditorBinding <T>(RowBinding <T> editorRowBinding, string paramName) where T : UIElement, new() { if (editorRowBinding == null) { throw new ArgumentNullException(paramName); } var rowInput = editorRowBinding.Input; if (rowInput == null) { throw new ArgumentException(DiagnosticMessages.InPlaceEditor_VerifyEditorBinding, paramName); } return(rowInput); }
/// <summary> /// Binds column to <see cref="Label"/>. /// </summary> /// <typeparam name="TTarget">The element type of target row binding.</typeparam> /// <param name="source">The source column.</param> /// <param name="target">The target row binding.</param> /// <param name="format">A composite format string.</param> /// <param name="formatProvider">An object that supplies culture-specific formatting information.</param> /// <returns>The row binding object.</returns> public static RowBinding <Label> BindToLabel <TTarget>(this Column source, RowBinding <TTarget> target, string format = null, IFormatProvider formatProvider = null) where TTarget : UIElement, new() { if (source == null) { throw new ArgumentNullException(nameof(source)); } return(new RowBinding <Label>( onSetup: (v, p) => { v.Content = source.DisplayName.ToString(format, formatProvider); if (target != null) { v.Target = target.SettingUpElement; } }, onRefresh: null, onCleanup: null)); }
private static RowBinding <ForeignKeyBox> WithInput(this RowBinding <ForeignKeyBox> rowBinding, CandidateKey foreignKey, Projection lookup) { var rowInput = rowBinding.BeginInput(ForeignKeyBox.ValueBagProperty); foreach (var columnSort in foreignKey) { rowInput.WithFlush(columnSort.Column, v => v.ValueBag); } if (lookup != null) { foreach (var column in lookup.GetColumns()) { if (column.IsExpression) { continue; } rowInput.WithFlush(column, v => v.ValueBag); } } return(rowInput.EndInput()); }
private static IColumns GetTargetColumns(IColumns result, RowBinding binding) { Debug.Assert(binding != null); var input = binding.RowInput; if (input != null) { return(result.Union(input.Target)); } var childBindings = binding.ChildBindings; if (childBindings == null) { return(result); } for (int i = 0; i < childBindings.Count; i++) { result = GetTargetColumns(result, childBindings[i]); } return(result); }
/// <summary> /// Binds collection of <see cref="RowBinding"/> to <see cref="ValidationPlaceholder"/>. /// </summary> /// <param name="source">The source bindings.</param> /// <returns>The row binding object.</returns> public static RowBinding <ValidationPlaceholder> BindToValidationPlaceholder(this IReadOnlyList <RowBinding> source) { source.VerifyNotNull(nameof(source)); var columns = GetTargetColumns(source); var input = new RowBinding <ValidationPlaceholder>(onSetup: (v, p) => { var containingElements = new UIElement[source.Count]; for (int i = 0; i < containingElements.Length; i++) { containingElements[i] = source[i].GetSettingUpElement(); } v.Setup(containingElements); }, onRefresh: null, onCleanup: (v, p) => { v.Cleanup(); }).BeginInput(new ExplicitTrigger <ValidationPlaceholder>()); foreach (var column in columns) { input.WithFlush(column, (r, v) => true); } return(input.EndInput()); }
public void RowBinding() { var dataSet = DataSetMock.ProductCategories(1); var _ = dataSet._; RowBinding <Label> label = null; RowBinding <TextBlock> textBlock = null; var elementManager = dataSet.CreateElementManager(builder => { textBlock = _.Name.BindToTextBlock(); label = _.Name.BindToLabel(textBlock); builder.GridColumns("100", "100").GridRows("100") .AddBinding(0, 0, label) .AddBinding(1, 0, textBlock); }); Assert.IsNull(label.SettingUpElement); Assert.IsNull(textBlock.SettingUpElement); var currentRow = elementManager.Rows[0]; Assert.AreEqual(_.Name.DisplayName, label[currentRow].Content); Assert.AreEqual(currentRow.GetValue(_.Name), textBlock[currentRow].Text); Assert.AreEqual(textBlock[currentRow], label[currentRow].Target); }
/// <summary> /// Merges editor row binding into <see cref="GridCell"/>, with inert element displays as string. /// </summary> /// <typeparam name="T">The element type of the editor row binding.</typeparam> /// <param name="editorRowBinding">The editor row binding.</param> /// <param name="format">A composite format string.</param> /// <param name="formatProvider">An object that supplies culture-specific formatting information.</param> /// <returns>The row binding object of <see cref="GridCell"/>.</returns> public static RowCompositeBinding <GridCell> MergeIntoGridCell <T>(this RowBinding <T> editorRowBinding, string format = null, IFormatProvider formatProvider = null) where T : UIElement, new() { return(editorRowBinding.MergeIntoInPlaceEditor(format, formatProvider).AddToGridCell()); }
/// <summary> /// Merges editor row binding into <see cref="InPlaceEditor"/>, with inert row binding. /// </summary> /// <typeparam name="TEditor">The element type of the editor row binding.</typeparam> /// <typeparam name="TInert">The element type of the inert row binding.</typeparam> /// <param name="editorRowBinding">The editor row binding.</param> /// <param name="inertRowBinding">The inert row binding.</param> /// <returns>The row binding object of <see cref="InPlaceEditor"/>.</returns> public static RowBinding <InPlaceEditor> MergeIntoInPlaceEditor <TEditor, TInert>(this RowBinding <TEditor> editorRowBinding, RowBinding <TInert> inertRowBinding) where TEditor : UIElement, new() where TInert : UIElement, new() { var rowInput = VerifyEditorBinding(editorRowBinding, nameof(editorRowBinding)); inertRowBinding.VerifyNotNull(nameof(inertRowBinding)); return(MergeIntoInPlaceEditor(rowInput, inertRowBinding)); }
/// <summary> /// Returns the operation that set initial focus to explicit row binding. /// </summary> /// <param name="binding">The row binding.</param> /// <returns>The result <see cref="InitialFocus"/>.</returns> public static InitialFocus Explicit(RowBinding binding) { binding.VerifyNotNull(nameof(binding)); return(new MoveToRowBinding(binding)); }
public MoveToRowBinding(RowBinding binding) { Debug.Assert(binding != null); _binding = binding; }
private static RowBinding <InPlaceEditor> MergeIntoInPlaceEditor <TEditing, TInert>(this RowInput <TEditing> rowInput, RowBinding <TInert> inertRowBinding) where TEditing : UIElement, new() where TInert : UIElement, new() { Debug.Assert(rowInput != null); Debug.Assert(inertRowBinding != null); return(InPlaceEditor.AddToInPlaceEditor(rowInput, inertRowBinding)); }
/// <summary> /// Adds row binding. /// </summary> /// <param name="column">Index of grid column.</param> /// <param name="row">Index of grid row.</param> /// <param name="rowBinding">The row binding.</param> /// <returns>This template builder for fluent coding.</returns> public TemplateBuilder AddBinding(int column, int row, RowBinding rowBinding) { return(AddBinding(column, row, column, row, rowBinding)); }
internal RowInput(RowBinding <T> rowBinding, Trigger <T> flushTrigger, Trigger <T> progressiveFlushTrigger) : base(flushTrigger, progressiveFlushTrigger) { RowBinding = rowBinding; }
/// <summary> /// Merges editor row binding into <see cref="GridCell"/>, with inert row binding. /// </summary> /// <typeparam name="TEditor">The element type of the editor row binding.</typeparam> /// <typeparam name="TInert">The element type of the inert row binding.</typeparam> /// <param name="editorRowBinding">The editor row binding.</param> /// <param name="inertRowBinding">The inert row binding.</param> /// <returns>The row binding object of <see cref="GridCell"/>.</returns> public static RowCompositeBinding <GridCell> MergeIntoGridCell <TEditor, TInert>(this RowBinding <TEditor> editorRowBinding, RowBinding <TInert> inertRowBinding) where TEditor : UIElement, new() where TInert : UIElement, new() { return(editorRowBinding.MergeIntoInPlaceEditor(inertRowBinding).AddToGridCell()); }
/// <summary> /// Adds row binding. /// </summary> /// <param name="left">Index of left grid column.</param> /// <param name="top">Index of top grid row.</param> /// <param name="right">Index of right grid column.</param> /// <param name="bottom">Index of bottom grid row.</param> /// <param name="rowBinding">The row binding.</param> /// <returns>This template builder for fluent coding.</returns> public TemplateBuilder AddBinding(int left, int top, int right, int bottom, RowBinding rowBinding) { Binding.VerifyAdding(rowBinding, nameof(rowBinding)); Template.AddBinding(Template.Range(left, top, right, bottom), rowBinding); return(this); }