An editor supporting smileys is most important feature nowadays. Any chat editors should render smileys from a piece of text. For example, ":)" denotes a smiling face. This article helps you to create an extended rich text editor which support smileys. [Read more]
Tuesday, 28 May 2013
Monday, 6 May 2013
GIF Animation in WPF
GIF images cannot be used directly in a WPF application. There are lot of third party libraries which support GIF images in WPF. Here is one which could play animated sprite sheets in WPF. [Read more]
Wednesday, 1 May 2013
Text binding to WinRT RichTextBlock
Normally it is not possible to bind text to WinRT RichTextBlock as we do for TextBlock. RichTextBlock is devoid of Text dependency property. So the only way is to populate the Blocks property with paragraphs in code behind. But by simply declaring an attached property, we can achieve binding to text in RichTextBlock.
1: public static string GetText(DependencyObject obj)
2: {
3: return (string)obj.GetValue(TextProperty);
4: }
5:
6: public static void SetText(DependencyObject obj, string value)
7: {
8: obj.SetValue(TextProperty, value);
9: }
10:
11: // Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
12: public static readonly DependencyProperty TextProperty =
13: DependencyProperty.RegisterAttached("Text", typeof(string), typeof(BindingHelper), new PropertyMetadata(String.Empty, OnTextChanged));
14:
15: private static void OnTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
16: {
17: var control = sender as RichTextBlock;
18: if (control != null)
19: {
20: control.Blocks.Clear();
21: string value = e.NewValue.ToString();
22:
23: var paragraph = new Paragraph();
24: paragraph.Inlines.Add(new Run {Text = value});
25: control.Blocks.Add(paragraph);
26: }
27: }
The XAML side binding will looks like below,
<RichTextBlock common1:BindingHelper.Text="{Binding ElementName=calendar, Path=SelectedDate}"/>
Subscribe to:
Posts (Atom)
