コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }