private void ProcessText() { if (Control == null || Element == null) { return; } // Gets the complete HTML string var isRtl = Device.FlowDirection == Xamarin.Forms.FlowDirection.RightToLeft; var styledHtml = new RendererHelper(Element, Element.Text, Device.RuntimePlatform, isRtl).ToString(); if (styledHtml == null) { return; } Control.Text = styledHtml; // Adds the HtmlTextBehavior because UWP's TextBlock // does not natively support HTML content var behavior = new HtmlTextBehavior((HtmlLabel)Element); BehaviorCollection behaviors = Interaction.GetBehaviors(Control); behaviors.Clear(); behaviors.Add(behavior); }
private void UpdateText() { if (Control == null || Element == null) { return; } if (string.IsNullOrEmpty(Control.Text)) { return; } // Gets the complete HTML string var helper = new LabelRendererHelper(Element, Element.Text); Control.Text = helper.ToString(); // Adds the HtmlTextBehavior because UWP's TextBlock // does not natively support HTML content var behavior = new HtmlTextBehavior((HtmlLabel)Element); BehaviorCollection behaviors = Interaction.GetBehaviors(Control); behaviors.Clear(); behaviors.Add(behavior); }
private static void OnPropertyChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e) { var uie = dpo as UIElement; if (uie == null) { return; } BehaviorCollection itemBehaviors = Interaction.GetBehaviors(uie); var newBehaviors = e.NewValue as StyleBehaviorCollection; var oldBehaviors = e.OldValue as StyleBehaviorCollection; if (newBehaviors == oldBehaviors) { return; } //if (oldBehaviors != null) //{ // foreach (var behavior in oldBehaviors) // { // int index = GetIndexOf(itemBehaviors, behavior); // if (index >= 0) // { // itemBehaviors.RemoveAt(index); // } // } //} itemBehaviors.Clear(); if (newBehaviors != null) { foreach (var behavior in newBehaviors) { int index = GetIndexOf(itemBehaviors, behavior); if (index < 0) { var clone = (Behavior)behavior.Clone(); Guid cloneId = GetBehaviorId(clone); if (cloneId == Guid.Empty) { SetBehaviorId(clone, Guid.NewGuid()); } itemBehaviors.Add(clone); } } } }
public static bool ClearManipulator(LayerControl SectionLayer) { if (SectionLayer == null) { return(false); } BehaviorCollection bc = Interaction.GetBehaviors(SectionLayer); bc.Clear(); return(true); }
public static bool SetManipulator(ManipulatorBase mp, LayerControl SectionLayer) { if (mp == null || SectionLayer == null) { return(false); } BehaviorCollection bc = Interaction.GetBehaviors(SectionLayer); bc.Clear(); bc.Add(mp); return(true); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (Interlocked.Exchange(ref _lazyContext, DataContext.Empty) == DataContext.Empty) { return; } OnDispose(); BindingServiceProvider.BindingManager.Unregister(this); BindingUpdated = null; BindingException = null; _behaviors.Clear(); _sourceAccessor.Dispose(); _targetAccessor.Dispose(); }
private static void OnBehaviorsChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) { if (e.NewValue is IEnumerable == false) { return; } var newBehaviorCollection = e.NewValue as IEnumerable; BehaviorCollection behaviorCollection = Interaction.GetBehaviors(depObj); behaviorCollection.Clear(); foreach (Behavior behavior in newBehaviorCollection) { behaviorCollection.Add(behavior); } }
private static void OnBehaviorsChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) { if (e.NewValue is BehaviorCreatorCollection == false) { return; } BehaviorCreatorCollection newBehaviorCollection = e.NewValue as BehaviorCreatorCollection; BehaviorCollection behaviorCollection = Interaction.GetBehaviors(depObj); behaviorCollection.Clear(); foreach (IBehaviorCreator behavior in newBehaviorCollection) { behaviorCollection.Add(behavior.Create()); } }
private static void OnPropertyChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e) { var uie = dpo as UIElement; if (uie == null) { return; } BehaviorCollection itemBehaviors = Interaction.GetBehaviors(uie); itemBehaviors.Clear(); var clone = (Behavior)(e.NewValue as BorderlessWindowBehavior).Clone(); itemBehaviors.Add(clone); }
private static void OnBehaviorsChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) { if (e.NewValue is IEnumerable == false) { return; } var newBehaviorCollection = e.NewValue as IEnumerable; BehaviorCollection behaviorCollection = Interaction.GetBehaviors(depObj); behaviorCollection.Clear(); foreach (Behavior behavior in newBehaviorCollection) { // you need to make a copy of behavior in order to attach it to several controls var copy = behavior.Clone() as Behavior; behaviorCollection.Add(copy); } }
public void VectorChanged_ResetWhileNotAttached_DetachNotCalled() { StubBehavior[] behaviorArray = { new StubBehavior(), new StubBehavior(), new StubBehavior() }; BehaviorCollection behaviorCollection = new BehaviorCollection(); foreach (StubBehavior behavior in behaviorArray) { behaviorCollection.Add(behavior); } behaviorCollection.Clear(); foreach (StubBehavior behavior in behaviorArray) { TestUtilities.AssertNotDetached(behavior); } }