From 28986641046c8ee1dc2aba0055dfa36b811b25d2 Mon Sep 17 00:00:00 2001 From: k0st1x Date: Sun, 30 Sep 2012 23:22:25 +0400 Subject: replace TextBlock by RichTextBox --- Juick/Classes/ParagraphBindingBehavior.cs | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Juick/Classes/ParagraphBindingBehavior.cs (limited to 'Juick/Classes/ParagraphBindingBehavior.cs') diff --git a/Juick/Classes/ParagraphBindingBehavior.cs b/Juick/Classes/ParagraphBindingBehavior.cs new file mode 100644 index 0000000..6a05579 --- /dev/null +++ b/Juick/Classes/ParagraphBindingBehavior.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using System.Windows; +using System.Windows.Documents; + +namespace Juick.Classes +{ + public static class ParagraphBindingBehavior + { + static void AssignedInlinesCallback(DependencyObject target, DependencyPropertyChangedEventArgs e) + { + var inlines = ((Paragraph)target).Inlines; + inlines.Clear(); + var value = e.NewValue as IEnumerable; + if (value != null) + { + foreach (var inline in value) + { + inlines.Add(inline); + } + } + } + + public static IEnumerable GetAssignedInlines(DependencyObject obj) + { + return (IEnumerable)obj.GetValue(AssignedInlinesProperty); + } + + public static void SetAssignedInlines(DependencyObject obj, IEnumerable value) + { + obj.SetValue(AssignedInlinesProperty, value); + } + + public static readonly DependencyProperty AssignedInlinesProperty = + DependencyProperty.RegisterAttached("AssignedInlines", typeof(IEnumerable), typeof(Paragraph), new PropertyMetadata(null, AssignedInlinesCallback)); + } +} -- cgit v1.2.3