public void BlockCompositeBinding_XAML() { var dataSet = DataSetMock.ProductCategories(1); var _ = dataSet._; BlockBinding <Label> blockLabel = null; BlockBinding <TextBlock> blockHeader = null; BlockCompositeBinding <XamlPane> pane = null; var elementManager = dataSet.CreateElementManager(builder => { blockHeader = _.AsBlockHeader(); blockLabel = _.Name.AsBlockLabel(blockHeader); pane = new BlockCompositeBinding <XamlPane>().AddChild(blockLabel, v => v.Label).AddChild(blockHeader, v => v.TextBlock); builder.Layout(Orientation.Vertical, 2) .GridColumns("100", "100").GridRows("100").RowRange(1, 0, 1, 0) .AddBinding(0, 0, pane); }); Assert.IsNull(blockLabel.SettingUpElement); Assert.IsNull(blockHeader.SettingUpElement); Assert.IsNull(pane.GetSettingUpElement()); var currentRow = elementManager.Rows[0]; Assert.AreEqual(pane[0].Children[0], blockLabel[0]); Assert.AreEqual(pane[0].Children[1], blockHeader[0]); Assert.AreEqual(_.Name.DisplayName, blockLabel[0].Content); Assert.AreEqual("0", blockHeader[0].Text); Assert.AreEqual(blockHeader[0], blockLabel[0].Target); }
public void BlockBinding() { var dataSet = DataSetMock.ProductCategories(1); var _ = dataSet._; BlockBinding <Label> blockLabel = null; BlockBinding <TextBlock> blockHeader = null; var elementManager = dataSet.CreateElementManager(builder => { blockHeader = _.AsBlockHeader(); blockLabel = _.Name.AsBlockLabel(blockHeader); builder.Layout(Orientation.Vertical, 2) .GridColumns("100", "100", "100").GridRows("100").RowRange(2, 0, 2, 0) .AddBinding(0, 0, blockLabel) .AddBinding(1, 0, blockHeader); }); Assert.IsNull(blockLabel.SettingUpElement); Assert.IsNull(blockHeader.SettingUpElement); var currentRow = elementManager.Rows[0]; Assert.AreEqual(_.Name.DisplayName, blockLabel[0].Content); Assert.AreEqual("0", blockHeader[0].Text); Assert.AreEqual(blockHeader[0], blockLabel[0].Target); }
/// <summary> /// Adds behavior to block binding. /// </summary> /// <typeparam name="T">Element type of row binding.</typeparam> /// <param name="blockBinding">The block binding.</param> /// <param name="behavior">The behavior.</param> /// <returns>The block binding for fluent coding.</returns> public static BlockBinding <T> AddBehavior <T>(this BlockBinding <T> blockBinding, IBlockBindingBehavior <T> behavior) where T : UIElement, new() { if (behavior == null) { throw new ArgumentNullException(nameof(behavior)); } blockBinding.InternalAddBehavior(behavior); return(blockBinding); }
/// <summary> /// Adds child binding. /// </summary> /// <typeparam name="TChild">Type of child binding target UI element.</typeparam> /// <param name="childBinding">The child binding.</param> /// <param name="childGetter">The getter to return child UI element.</param> /// <returns>This composite binding for fluent coding.</returns> public BlockCompositeBinding <T> AddChild <TChild>(BlockBinding <TChild> childBinding, Func <T, TChild> childGetter) where TChild : UIElement, new() { Binding.VerifyAdding(childBinding, nameof(childBinding)); if (childGetter == null) { throw new ArgumentNullException(nameof(childGetter)); } VerifyNotSealed(); _childBindings.Add(childBinding); _childGetters.Add(childGetter); childBinding.Seal(this, _childBindings.Count - 1); return(this); }
public static BlockBinding <Label> AsBlockLabel <T>(this Column source, BlockBinding <T> target) where T : UIElement, new() { return(new BlockBinding <Label>( onSetup: (e, bp) => { e.Content = source.DisplayName; if (target != null) { e.Target = target.SettingUpElement; } }, onRefresh: (e, bp) => { }, onCleanup: (e, bp) => { })); }
/// <summary> /// Adds block 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="blockBinding">The block binding.</param> /// <returns>This template builder for fluent coding.</returns> public TemplateBuilder AddBinding(int left, int top, int right, int bottom, BlockBinding blockBinding) { Binding.VerifyAdding(blockBinding, nameof(blockBinding)); Template.AddBinding(Template.Range(left, top, right, bottom), blockBinding); return(this); }
/// <summary> /// Adds block binding. /// </summary> /// <param name="column">Index of grid column.</param> /// <param name="row">Index of grid row.</param> /// <param name="blockBinding">The block binding.</param> /// <returns>This template builder for fluent coding.</returns> public TemplateBuilder AddBinding(int column, int row, BlockBinding blockBinding) { return(AddBinding(column, row, column, row, blockBinding)); }