저는 RX 프레임 워크를 처음 사용합니다. Im은 InotifyPropertyChanged를 사용하여 속성을 업데이트 할 때 Silverlight 텍스트 상자를 업데이트하려고 시도하고 있습니다. 내 XAML은 다음과 같습니다Reactive Framework 및 Silverlight로 INotifyPropertyChangeed
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;
}
내 문제가 있다는 것이다 프로퍼티 변경 이벤트를 처리 할 다른 클래스를 생성 : 뒤에 내 코드에서
<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>
, 내가 가진 텍스트 상자에 입력 한 내용에서 Textblock의 출력물을 얻지 못합니다. 또한 내가 잘못 사용하는 경우 알려 주시기 바랍니다 ...
아이디어가 있으십니까? 미리 감사드립니다!
Rx 프레임 워크와 Observable을 사용하는 목적을 꺾지 않습니까? – Mage
나는 그렇게 생각하지 않는다. 올바른 데이터를 시각화하기 위해 올바른 바인딩을해야한다. –
당신이하는 일은 텍스트 박스를 텍스트 블록에 바인딩하는 것이다. 괜찮 았지만 내가하고 싶은 것은 아닙니다. Oberserver가 데이터를 내게 밀어주기를 원합니다 (Textblock에 대한 의미). – Mage