summaryrefslogtreecommitdiff
path: root/Juick/Classes/ParagraphBindingBehavior.cs
diff options
context:
space:
mode:
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));
+ }
+}