static void OnSourcePropertyChanged(BindableObject bindable, object oldValue, object newValue) { if (newValue != null) { BindableObject.SetInheritedBindingContext(newValue as BindableObject, bindable.BindingContext); } }
internal void SetInheritedBindingContext(object bindingContext) { foreach (var item in Items) { BindableObject.SetInheritedBindingContext(item, bindingContext); } }
public (UIView NativeView, VisualElement FormsElement) RealizeEmptyView(object emptyView, DataTemplate emptyViewTemplate) { if (emptyViewTemplate != null) { // We have a template; turn it into a Forms view var templateElement = emptyViewTemplate.CreateContent() as View; var renderer = CreateRenderer(templateElement); // and set the EmptyView as its BindingContext BindableObject.SetInheritedBindingContext(renderer.Element, emptyView); return(renderer.NativeView, renderer.Element); } if (emptyView is View formsView) { // No template, and the EmptyView is a Forms view; use that var renderer = CreateRenderer(formsView); return(renderer.NativeView, renderer.Element); } // No template, EmptyView is not a Forms View, so just display EmptyView.ToString var label = new UILabel { Text = emptyView.ToString() }; return(label, null); }
/// From the Container base class. /// <summary> /// Adds a child view to this layer. /// </summary> /// <seealso cref="Container.Add"> /// </seealso> /// <exception cref="ArgumentNullException"> Thrown when child is null. </exception> /// <since_tizen> 4 </since_tizen> public override void Add(View child) { if (null == child) { throw new ArgumentNullException(nameof(child)); } Container oldParent = child.GetParent(); if (oldParent != this) { if (oldParent != null) { oldParent.Remove(child); } else { child.InternalParent = this; } Interop.Actor.Add(SwigCPtr, View.getCPtr(child)); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } Children.Add(child); BindableObject.SetInheritedBindingContext(child, this?.BindingContext); } }
public static (UIView NativeView, VisualElement FormsElement) RealizeView(object view, DataTemplate viewTemplate, ItemsView itemsView) { if (viewTemplate != null) { // Run this through the extension method in case it's really a DataTemplateSelector viewTemplate = viewTemplate.SelectDataTemplate(view, itemsView); // We have a template; turn it into a Forms view var templateElement = viewTemplate.CreateContent() as View; var renderer = CreateRenderer(templateElement); // and set the EmptyView as its BindingContext BindableObject.SetInheritedBindingContext(renderer.Element, view); return(renderer.NativeView, renderer.Element); } if (view is View formsView) { // No template, and the EmptyView is a Forms view; use that var renderer = CreateRenderer(formsView); return(renderer.NativeView, renderer.Element); } return(new UILabel { Text = $"{view}" }, null); }
static void OnSourcePropertyChanged(BindableObject bindable, object oldValue, object newValue) { if (newValue != null) { BindableObject.SetInheritedBindingContext(newValue as BindableObject, bindable.BindingContext); } ((CachedImage)bindable).InvalidateMeasure(); }
static void OnSourcePropertyChanged(BindableObject bindable, object oldValue, object newValue) { if (newValue != null) { BindableObject.SetInheritedBindingContext(newValue as BindableObject, bindable.BindingContext); } ((IVisualElementController)bindable).NativeSizeChanged(); }
protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); foreach (BindableObject gradientStop in (Collection <DGradientStop>) this.GradientStops) { BindableObject.SetInheritedBindingContext(gradientStop, this.BindingContext); } }
void SetCell(object newContext) { var cell = newContext as Cell; if (cell != null) { Cell = cell; return; } if (ReferenceEquals(Cell?.BindingContext, newContext)) { return; } // If there is a ListView, load the Cell content from the ItemTemplate. // Otherwise, the given Cell is already a templated Cell from a TableView. ListView lv = _listView.Value; if (lv != null) { bool isGroupHeader = IsGroupHeader; DataTemplate template = isGroupHeader ? lv.GroupHeaderTemplate : lv.ItemTemplate; object bindingContext = newContext; if (template is DataTemplateSelector) { template = ((DataTemplateSelector)template).SelectTemplate(bindingContext, lv); } if (template != null) { cell = template.CreateContent() as Cell; } else { if (isGroupHeader) { bindingContext = lv.GetDisplayTextFromGroup(bindingContext); } cell = lv.CreateDefaultCell(bindingContext); } // A TableView cell should already have its parent, // but we need to set the parent for a ListView cell. cell.Parent = lv; // Set inherited BindingContext after setting the Parent so it won't be wiped out BindableObject.SetInheritedBindingContext(cell, bindingContext); // This provides the Group Header styling (e.g., larger font, etc.) when the // template is loaded later. cell.SetIsGroupHeader <ItemsView <Cell>, Cell>(isGroupHeader); } Cell = cell; }
private void SetupItems(IList items, BindableObject parent) { foreach (BindableObject item in items) { BindableObject.SetInheritedBindingContext(item, parent?.BindingContext); var element = (IWithParentElement)item; element.Parent = parent; } }
protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); if (this.BackgroundBrush == null) { return; } BindableObject.SetInheritedBindingContext((BindableObject)this.BackgroundBrush, this.BindingContext); }
private static void OnAudioPlayerBarChanged(BindableObject bindable, object oldValue, object newValue) { var newElement = (Element)newValue; if (newElement != null) { BindableObject.SetInheritedBindingContext(newElement, bindable.BindingContext); } }
private void SetupItems(IList items, SKCanvasView parent) { foreach (var item in items) { var element = (TElement)item; BindableObject.SetInheritedBindingContext(element, parent?.BindingContext); element.Parent = parent; } }
// // Methods // protected override void OnBindingContextChanged() { if (this.Source != null) { BindableObject.SetInheritedBindingContext(Source, BindingContext); } base.OnBindingContextChanged(); }
internal void Release() { Parent = null; foreach (var item in Items) { BindableObject.SetInheritedBindingContext(item, null); item.Parent = null; } }
private static void OnBindingContextChanged(object sender, System.EventArgs e) { var skCanvasView = (SKCanvasView)sender; var rendererSource = GetRenderer(skCanvasView); if (rendererSource is BindableObject bindable) { BindableObject.SetInheritedBindingContext(bindable, skCanvasView.BindingContext); } }
void ApplyTemplateAndDataContext(TemplatedCell cell, NSIndexPath indexPath) { // We need to create a renderer, which means we need a template var view = _itemsView.ItemTemplate.CreateContent() as View; _itemsView.AddLogicalChild(view); var renderer = CreateRenderer(view); BindableObject.SetInheritedBindingContext(view, _itemsSource[indexPath.Row]); cell.SetRenderer(renderer); }
public static void SetBindingContext(this IGradientControl control, object bindingContext) { if (control.GradientSource is BindableObject bindable) { BindableObject.SetInheritedBindingContext(bindable, bindingContext); } if (control.Mask is BindableObject maskBindable) { BindableObject.SetInheritedBindingContext(maskBindable, bindingContext); } }
void ApplyTemplateAndDataContext(TemplatedCell cell, NSIndexPath indexPath) { // We need to create a renderer, which means we need a template var templateElement = _itemsView.ItemTemplate.CreateContent() as View; IVisualElementRenderer renderer = CreateRenderer(templateElement); if (renderer != null) { BindableObject.SetInheritedBindingContext(renderer.Element, _itemsSource[indexPath.Row]); cell.SetRenderer(renderer); } }
internal void AttachTo(SKCanvasView parent) { Parent = parent; foreach (var item in Items) { BindableObject.SetInheritedBindingContext(item, Parent?.BindingContext); item.Parent = parent; } Parent?.InvalidateSurface(); }
internal void AttachTo(BindableObject parent) { Parent = parent; foreach (var item in Items) { BindableObject.SetInheritedBindingContext(item, Parent?.BindingContext); item.Parent = parent; } InvalidateParentCanvas(); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder) { case TextViewHolder textViewHolder: textViewHolder.TextView.Text = _itemsSource[position].ToString(); break; case TemplatedItemViewHolder templateViewHolder: BindableObject.SetInheritedBindingContext(templateViewHolder.View, _itemsSource[position]); break; } }
public override void InsertListRange(int index, IEnumerable <TemplatedItem <UIMeshItem> > enumerable) { var mesh = (UIMesh)container; var oldCount = _builder.Count; _builder.InsertRange(index, enumerable); foreach (var item in _builder.Skip(oldCount)) { BindableObject.SetInheritedBindingContext(item.Content, mesh.BindingContext); item.Content.mesh = mesh; } mesh.Body?.SetVerticesDirty(); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (EmptyView == null || EmptyViewTemplate == null) { return; } if (!(holder is EmptyViewHolder emptyViewHolder)) { return; } // Use EmptyView as the binding context for the template BindableObject.SetInheritedBindingContext(emptyViewHolder.View, EmptyView); }
protected override void OnElementChanged(ElementChangedEventArgs <MediaElement> e) { if (e.OldElement != null) { e.OldElement.SeekRequested -= OnSeekRequested; e.OldElement.StateRequested -= OnStateRequested; e.OldElement.PositionRequested -= OnPositionRequested; } if (Control == null) { SetNativeControl(new LayoutCanvas(XForms.NativeParent)); _mediaView = new MediaView(XForms.NativeParent); Control.LayoutUpdated += (s, evt) => OnLayout(); Control.Children.Add(_mediaView); Control.AllowFocus(true); _player = new MediaPlayer() { VideoOutput = this }; _player.PlaybackStarted += OnPlaybackStarted; _player.PlaybackPaused += OnPlaybackPaused; _player.PlaybackStopped += OnPlaybackStopped; _player.PlaybackCompleted += OnPlaybackCompleted; _player.BufferingProgressUpdated += OnBufferingProgressUpdated; _player.ErrorOccurred += OnErrorOccurred; _player.MediaPrepared += OnMediaPrepared; _player.BindingContext = Element; _player.SetBinding(MediaPlayer.SourceProperty, "Source"); _player.SetBinding(MediaPlayer.UsesEmbeddingControlsProperty, "ShowsPlaybackControls"); _player.SetBinding(MediaPlayer.AutoPlayProperty, "AutoPlay"); _player.SetBinding(MediaPlayer.VolumeProperty, "Volume"); _player.SetBinding(MediaPlayer.IsLoopingProperty, "IsLooping"); _player.SetBinding(MediaPlayer.AspectModeProperty, new Binding { Path = "Aspect", Converter = new AspectToDisplayAspectModeConverter() }); BindableObject.SetInheritedBindingContext(_player, Element.BindingContext); Element.SeekRequested += OnSeekRequested; Element.StateRequested += OnStateRequested; Element.PositionRequested += OnPositionRequested; } base.OnElementChanged(e); }
// From Container Base class /// <summary> /// Adds a child view to this view. /// </summary> /// <seealso cref="Container.Add" /> /// <since_tizen> 4 </since_tizen> public override void Add(View child) { bool hasLayout = (_layout != null); if (null == child) { Tizen.Log.Fatal("NUI", "Child is null"); return; } Container oldParent = child.GetParent(); if (oldParent != this) { // If child already has a parent then re-parent child if (oldParent != null) { if (child.Layout != null) { child.Layout.SetReplaceFlag(); } oldParent.Remove(child); } child.InternalParent = this; Interop.Actor.Actor_Add(swigCPtr, View.getCPtr(child)); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } Children.Add(child); if (ChildAdded != null) { ChildAddedEventArgs e = new ChildAddedEventArgs { Added = child }; ChildAdded(this, e); } BindableObject.SetInheritedBindingContext(child, this?.BindingContext); } }
public override void ReplaceListRange(int index, int count, IEnumerable <TemplatedItem <UIMeshItem> > enumerable) { var mesh = (UIMesh)container; foreach (var item in _builder.Skip(index).Take(count)) { item.Content.Dispose(); } base.ReplaceListRange(index, count, enumerable); foreach (var item in _builder.Skip(index).Take(count)) { BindableObject.SetInheritedBindingContext(item.Content, mesh.BindingContext); item.Content.mesh = mesh; } mesh.Body?.SetVerticesDirty(); }
void ApplyTemplateAndDataContext(TemplatedCell cell, NSString elementKind, NSIndexPath indexPath) { DataTemplate template; if (elementKind == UICollectionElementKindSectionKey.Header) { template = GroupableItemsView.GroupHeaderTemplate; } else { template = GroupableItemsView.GroupFooterTemplate; } var templateElement = template.CreateContent() as View; var renderer = CreateRenderer(templateElement); BindableObject.SetInheritedBindingContext(renderer.Element, ItemsSource.Group(indexPath)); cell.SetRenderer(renderer); }
private void UpdateInheritedBindingContexts() { object bindingContext = base.BindingContext; RowDefinitionCollection rowDefs = this.RowDefinitions; if (rowDefs != null) { for (int i = 0; i < rowDefs.Count; i++) { BindableObject.SetInheritedBindingContext(rowDefs[i], bindingContext); } } ColumnDefinitionCollection colDefs = this.ColumnDefinitions; if (colDefs != null) { for (int j = 0; j < colDefs.Count; j++) { BindableObject.SetInheritedBindingContext(colDefs[j], bindingContext); } } }
protected override void OnBindingContextChanged() { BindableObject.SetInheritedBindingContext(Page, base.BindingContext); base.OnBindingContextChanged(); }