wpf xaml inlines

string testBold = "<Bold>Sync Now</Bold>";
           var ele = System.Windows.Markup.XamlReader.Parse(testBold);
           textBlock2.Inlines.Add(ele as Bold);

string str = (string)App.Current.Resources["IDS_TO_BEGIN_SYNC_FILES"];
           //str = str.Replace("(b)", "<Bold>");
           //str = str.Replace("(/b)", "</Bold>");
           //textBlock1.DataContext = str;
           // textBlock1.Inlines.Add(str);

int index = str.IndexOf("(b)");
           while (index != -1)
           {
               string run1 = str.Substring(0, index);
               textBlock1.Inlines.Add(run1);
               str = str.Substring(index + 3);
               index = str.IndexOf("(/b)");
               string bold = str.Substring(0, index);
               textBlock1.Inlines.Add(new Bold(new Run(bold)));
               str = str.Substring(index + 4);
               index = str.IndexOf("(b)");
           }
           textBlock1.Inlines.Add(str);

上一篇:03 Django模型层: 常用(非常用)字段和参数


下一篇:卡特兰数 (Catalan)