Я новичок в RX Framework. Я пытаюсь обновить текстовое поле Silverlight при обновлении свойства с помощью INotifyPropertyChanged. Мой XAML выглядит так:
<Canvas x:Name="LayoutRoot" Background="White">
<Border BorderThickness="2" CornerRadius="5" BorderBrush="Blue" Canvas.Left="12" Width="371">
<TextBlock Height="135" HorizontalAlignment="Left" Margin="12,50,0,0" Name="textBlock1"
Text=""
VerticalAlignment="Top" Width="367" />
</Border>
<Button Content="Post!" Height="23" HorizontalAlignment="Left" Margin="12,210,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<TextBox Height="41"
HorizontalAlignment="Left"
Margin="12,247,0,0"
Name="textBox1"
VerticalAlignment="Top"
Width="376"
/>
<sdk:Label Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="label1" VerticalAlignment="Top" Width="120" Content="Post Window" FontWeight="Bold" FontSize="12" Canvas.Left="14" Canvas.Top="0" />
</Canvas>
В моем коде есть:
public partial class MainPage : UserControl
{
Messanger messanger;
public MainPage()
{
InitializeComponent();
}
void messanger_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
var textBoxInput = from evt in Observable.FromEvent<PropertyChangedEventArgs>(messanger, "PropertyChanged")
select evt.EventArgs.PropertyName.Equals("PropertyName");
textBoxInput.Subscribe(value => textBlock1.Text = value.ToString());
}
private void button1_Click(object sender, RoutedEventArgs e)
{
messanger = new Messanger();
messanger.PropertyChanged += new PropertyChangedEventHandler(messanger_PropertyChanged);
messanger.Message = textBox1.Text;
}
}
и я создал еще один класс для обработки событий изменения свойства
public class Messanger : INotifyPropertyChanged
{
private string MessageValue;
public string Message
{
get { return MessageValue; }
set
{
MessageValue = value;
NotifyPropertyChanged("Message");
}
}
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
Моя проблема в том, что я не получаю вывод в Textblock от того, что я положил в Textbox. Также дайте мне знать, если я использую это неправильно ...
Есть идеи? Заранее спасибо!