tags:

views:

44

answers:

1

I do not have much experiece of WPF, and I consider it as an easier way to markup/coding UI in .net.

I have install the lastest Rx release, and play it using Console application without any issue, when I used it in a simple WPF application, it seems that 'Observable' is not liked by WPF...

I have added both reference to: System.CoreEx System.Reactive

when type in the button click's event handler, the VS intelligent happily pickup the Observable class and its static members, however when compile it, the 'Observable' becomes unknown to the context. Also the intelligence is gone for the class...

If I remove the above two reference, and add them back in again, the intelligence picked it up... when compile, same situation happens again...

I also installed the silverlight version of rx, not still not luck, please advice and help.

    private void btnStart_Click(object sender, RoutedEventArgs e)
    {
        CheckBox[] chbServers = new CheckBox[] { chbMx1, chbMx2, chbMx3, chbMx4 };
        ListBox[] lbxFiles = new ListBox[] { listBox1, listBox2, listBox3, listBox4 };


        for (int i = 0; i < chbServers.Length; ++i)
        {
            if (chbServers[i].IsChecked == true)
            {
                string baseDir = string.Format(@"c:\maildrop\mx{0}", i + 1);
                if (Directory.Exists(baseDir))
                {
                    DirectoryInfo di = new DirectoryInfo(baseDir);
                    FileInfo[] fis = di.GetFiles("*.eml", SearchOption.AllDirectories);

                    //Observable.GenerateWithTime(
                    //    0,
                    //    index => index <= fis.Length,
                    //    index => index + 1,
                    //    index => fis[index].Name,
                    //    _ => TimeSpan.FromMilliseconds(300)
                    //    )
                    //    .ObserveOnDispatcher()
                    //    .Subscribe(name =>
                    //    {
                    //        // delete the file
                    //        lbxFiles[i].Items.Remove(name);
                    //    }); 
                }
            }
        }
    }

The commented code is the piece which cause problem...

using System;
using System.Collections.Generic;
using System.Disposables;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;

all namespace refereced are as above...

+1  A: 

WPF applications use the .NET 4 Client Profile by default, which was not supported by Rx until the latest release. Changing your project settings to use the full .NET 4 framework will allow you to compile.

John Bowen
will try your suggestion, many thanks...
ccppjava