Hi guys i'm very very very new to Rx and trying to put together a simple test app. It basically subscribes to the window click event using Rx and sets the text on a textbox to "Clicked". It's a wpf app. Here's the xaml:
<Window x:Class="Reactive.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Canvas>
<TextBlock Name="txtClicked" Text="Rx Test"/>
</Canvas>
</Grid>
and here's the code behind:
using System;
using System.Linq;
using System.Windows;
using System.Windows.Input;
namespace Reactive
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// Initializes a new instance of the <see cref="MainWindow"/> class.
/// </summary>
public MainWindow()
{
InitializeComponent();
var xs = from evt in Observable.FromEvent<MouseEventArgs>(this, "MouseDown")
select evt;
xs.ObserveOnDispatcher().Subscribe(value => txtClicked.Text = "Clicked");
}
}
}
But for some reason the code doesn't run. i get the message:
The invocation of the constructor on type 'Reactive.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9
InnnerException message:
The event delegate must be of the form void Handler(object, T) where T : EventArgs.
Please help!!!