Ejemplo n.º 1
0
 /// <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)
     {
         BindableRun run = new BindableRun();
         if (dataContext is BindingBase)
         {
             run.SetBinding(BindableRun.DataContextProperty, (BindingBase)dataContext);
         }
         else
         {
             run.DataContext = dataContext;
         }
         run.SetBinding(BindableRun.BoundTextProperty, (BindingBase)data);
         return(new Paragraph(run));
     }
     else
     {
         Run run = new Run();
         run.Text = (data == null) ? String.Empty : data.ToString();
         return(new Paragraph(run));
     }
 }
Ejemplo n.º 2
0
        static void OnBindableTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            BindableRun br = (BindableRun)sender;

            br.Text = (string)e.NewValue;
        }