Tôi đang cố triển khai hình ảnh kéo và thả tiêu chuẩn trong wpf bằng Rx.Lỗi Không thể chuyển đổi biểu thức lambda trong đăng ký cho IObservable <Point>
var mouseDown = from evt in Observable.FromEventPattern<MouseButtonEventArgs>(image, "MouseLeftButtonDown")
select evt.EventArgs.GetPosition(image);
var mouseUp = Observable.FromEventPattern<MouseButtonEventArgs>(this, "MouseLeftButtonUp");
var mouseMove = from evt in Observable.FromEventPattern<MouseEventArgs>(this, "MouseMove")
select evt.EventArgs.GetPosition(this);
var q = from startLocation in mouseDown
from endLocation in mouseMove.TakeUntil(mouseUp)
select new Point
{
X = endLocation.X - startLocation.X,
Y = endLocation.Y - startLocation.Y
};
q.ObserveOn(SynchronizationContext.Current).Subscribe(point =>
{
Canvas.SetLeft(image, point.X);
Canvas.SetTop(image, point.Y);
});
tôi nhận được Lỗi lỗi Cannot convert lambda expression to type 'System.IObserver<System.Windows.Point>' because it is not a delegate type
những gì tôi bị mất?
Mã của bạn hoạt động tốt cho tôi. Bạn đã tham chiếu Rx-Main và Rx-WPF chưa? – Phil
vâng tôi đã tham chiếu cả hai. –
Hãy kiểm tra xem nền tảng mục tiêu của bạn có nói .NET 4 Client Profile không và sau đó thay đổi nó thành .NET 4. – Christoph