当前位置: 首页>>代码示例>>C#>>正文


C# Run.SetBinding方法代码示例

本文整理汇总了C#中System.Windows.Documents.Run.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# Run.SetBinding方法的具体用法?C# Run.SetBinding怎么用?C# Run.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Documents.Run的用法示例。


在下文中一共展示了Run.SetBinding方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertToBlock

        /// <summary>
        /// Convert "data" to a flow document block object. If data is already a block, the return value is data recast.
        /// </summary>
        /// <param name="dataContext">only used when bindable content needs to be created</param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static Block ConvertToBlock(object dataContext, object data)
        {
            if (data is Block)
                return (Block)data;
            else if (data is Inline)
                return new Paragraph((Inline)data);
            else if (data is BindingBase)
            {
                var run = new Run();

                if (dataContext is BindingBase)
                    run.SetBinding(Run.DataContextProperty, (BindingBase)dataContext);
                else
                    run.DataContext = dataContext;

                run.SetBinding(Run.TextProperty, (BindingBase)data);
                return new Paragraph(run);
            }
            else
            {
                var run = new Run();
                run.Text = (data == null) ? string.Empty : data.ToString();
                return new Paragraph(run);
            }
        }
开发者ID:Konctantin,项目名称:SpellWork,代码行数:31,代码来源:Helpers.cs

示例2: ConvertToBlock

        internal static Block ConvertToBlock(object dataContext, object data)
        {
            if (data is Block)
            {
                return (Block)data;
            }
            else if (data is Inline)
            {
                return new Paragraph((Inline)data);
            }
            else if (data is BindingBase)
            {
                Run run = new Run();

                if (dataContext is BindingBase)
                {
                    run.SetBinding(Run.DataContextProperty, (BindingBase)dataContext);
                }
                else
                {
                    run.DataContext = dataContext;
                }

                run.SetBinding(Run.TextProperty, (BindingBase)data);

                return new Paragraph(run);
            }
            else
            {
                Run run = new Run();
                run.Text = (data == null) ? String.Empty : data.ToString();
                return new Paragraph(run);
            }
        }
开发者ID:rodrigovedovato,项目名称:FlowDocumentReporting,代码行数:34,代码来源:Helpers.cs

示例3: SetPlaceholder

 protected void SetPlaceholder() {
     Inlines.Clear();
     var placeholder = Placeholder;
     if (!string.IsNullOrEmpty(placeholder)) {
         var inline = new Run { Text = placeholder };
         inline.SetBinding(TextElement.ForegroundProperty, new Binding {
             Path = new PropertyPath(nameof(Foreground)),
             Source = this,
             Converter = this
         });
         Inlines.Add(inline);
     }
 }
开发者ID:gro-ove,项目名称:actools,代码行数:13,代码来源:PlaceholderTextBlock.cs

示例4: CreateTextBlock

 public Run CreateTextBlock(string text, FontWeight weight, DependencyProperty foreground)
 {
     Run x = new Run (text);
     x.FontWeight = weight;
     if (foreground != null)
         x.SetBinding (Run.ForegroundProperty, CreateBinding (this, foreground.Name, BindingMode.OneWay));
     return x;
 }
开发者ID:atrandom,项目名称:ktwt,代码行数:8,代码来源:TwitterStatusViewer.xaml.cs

示例5: BuildElementInternal

 protected override Inline BuildElementInternal()
 {
     Run buildElementInternal;
     if (textBinding != null)
     {
         buildElementInternal = new Run();
         buildElementInternal.SetBinding(Run.TextProperty, textBinding);
     }
     else
         buildElementInternal = new Run(Text);
     if (style != null)
         buildElementInternal.SetResourceReference(FrameworkContentElement.StyleProperty, style);
     return buildElementInternal;
 }
开发者ID:JakeGinnivan,项目名称:XText,代码行数:14,代码来源:XRun.cs

示例6: ConvertToBlock

        /// <summary>
        /// Convert "data" to a flow document block object. If data is already a block, the return value is data recast.
        /// </summary>
        /// <param name="dataContext">only used when bindable content needs to be created</param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static Block ConvertToBlock(object dataContext, object data)
        {
            var block = data as Block;
            if (block != null) return block;
            var inline = data as Inline;
            if (inline != null) return new Paragraph(inline);

            var bindingBase = data as BindingBase;
            if (bindingBase != null)
            {
                var run = new Run();
                var dataContextBindingBase = dataContext as BindingBase;
                if (dataContextBindingBase != null)
                    run.SetBinding(DataContextProperty, dataContextBindingBase);
                else
                    run.DataContext = dataContext;
                run.SetBinding(Run.TextProperty, bindingBase);
                return new Paragraph(run);
            }
            return new Paragraph(new Run { Text = (data == null) ? string.Empty : data.ToString() });
        }
开发者ID:sat1582,项目名称:CODEFramework,代码行数:27,代码来源:RepeatingSection.cs

示例7: TextChanged

        private static void TextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Label lbl = d as Label;
            TextBlock block = d as TextBlock;

            if (lbl != null)
            {
                block = lbl.Content as TextBlock;

                if (block == null)
                {
                    string lblChild = lbl.Content as string;
                    TextBlock newChild = new TextBlock { Text = lblChild ?? "" };
                    lbl.Content = newChild;
                    block = newChild;
                }
            }

            if (block == null)
            {
                return;
            }

            string searchText = GetHighlightText(d);
            string blockText = GetSourceText(d);

            if (blockText == null)
            {
                return;
            }

            int last = 0;
            block.Inlines.Clear();

            if (!string.IsNullOrEmpty(searchText))
            {
                IReadOnlyList<PackageSearchUtil.Range> matches = PackageSearchUtil.ForTerm(searchText).GetMatchesInText(blockText);

                for (int i = 0; i < matches.Count; ++i)
                {
                    if (matches[i].Length == 0)
                    {
                        continue;
                    }

                    if (last < matches[i].Start)
                    {
                        string inserted = blockText.Substring(last, matches[i].Start - last);
                        block.Inlines.Add(inserted);
                        last += inserted.Length;
                    }

                    Run highlight = new Run(matches[i].ToString());
                    highlight.SetBinding(FrameworkContentElement.StyleProperty, new Binding
                    {
                        Mode = BindingMode.OneWay,
                        Source = d,
                        Path = new PropertyPath(HighlightStyleProperty)
                    });
                    block.Inlines.Add(highlight);
                    last += matches[i].Length;
                }
            }

            if (last < blockText.Length)
            {
                block.Inlines.Add(blockText.Substring(last));
            }
        }
开发者ID:madskristensen,项目名称:Packman,代码行数:69,代码来源:SearchHighlight.cs


注:本文中的System.Windows.Documents.Run.SetBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。