summaryrefslogtreecommitdiff
path: root/Juick/Classes/ParagraphBindingBehavior.cs
diff options
context:
space:
mode:
authorGravatar k0st1x2012-09-30 23:22:25 +0400
committerGravatar k0st1x2012-09-30 23:22:25 +0400
commit28986641046c8ee1dc2aba0055dfa36b811b25d2 (patch)
tree8ec69b4c461048403d1952428bf1ebb0ca7a1140 /Juick/Classes/ParagraphBindingBehavior.cs
parentc6c15caf54c6a648c7bd87c9161147ead4046988 (diff)
replace TextBlock by RichTextBox
Diffstat (limited to 'Juick/Classes/ParagraphBindingBehavior.cs')
-rw-r--r--Juick/Classes/ParagraphBindingBehavior.cs36
1 files changed, 36 insertions, 0 deletions
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<Inline>;
+ if (value != null)
+ {
+ foreach (var inline in value)
+ {
+ inlines.Add(inline);
+ }
+ }
+ }
+
+ public static IEnumerable<Inline> GetAssignedInlines(DependencyObject obj)
+ {
+ return (IEnumerable<Inline>)obj.GetValue(AssignedInlinesProperty);
+ }
+
+ public static void SetAssignedInlines(DependencyObject obj, IEnumerable<Inline> value)
+ {
+ obj.SetValue(AssignedInlinesProperty, value);
+ }
+
+ public static readonly DependencyProperty AssignedInlinesProperty =
+ DependencyProperty.RegisterAttached("AssignedInlines", typeof(IEnumerable<Inline>), typeof(Paragraph), new PropertyMetadata(null, AssignedInlinesCallback));
+ }
+}