C# 标签';XXX和x27;在XML命名空间中不存在';clr名称空间:XXX';

C# 标签';XXX和x27;在XML命名空间中不存在';clr名称空间:XXX';,c#,wpf,xaml,ivalueconverter,C#,Wpf,Xaml,Ivalueconverter,我有一个典型的标记“XXX”在XML名称空间“clr namespace:XXX”中不存在的问题,但我真的找不到哪里做错了 以下是错误消息: D:\CUI\Projects\fijilaunchester\fijilaunchester\Window1.xaml(9,14): 错误MC3074:标记“BoolToValueConverter”在XML中不存在 命名空间“clr命名空间:FijiLaunchTester”。第9行位置14。多恩 生成项目“FijiLaunchTester.cspro

我有一个典型的标记“XXX”在XML名称空间“clr namespace:XXX”中不存在的问题,但我真的找不到哪里做错了

以下是错误消息:

D:\CUI\Projects\fijilaunchester\fijilaunchester\Window1.xaml(9,14): 错误MC3074:标记“BoolToValueConverter”在XML中不存在 命名空间“clr命名空间:FijiLaunchTester”。第9行位置14。多恩 生成项目“FijiLaunchTester.csproj”--失败

xmal中的
local:BoolToValueConverter
是出错的地方,但我已经在xaml后面的C#代码中定义了它

xaml:


对
不
C#后面

使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Navigation;
使用System.Windows.Shapes;
使用FijiLauncher;
使用System.Windows.Forms;
使用System.IO;
命名空间测试器
{    
/// 
///Window1.xaml的交互逻辑
/// 
公共部分类Window1:Window
{
私人飞行情报管制(飞行情报);;
private System.Windows.Forms.Timer\u statusTimer;
公共字符串IjmFinished
{
获取{return Convert.ToString(_fl.IjmFinished);}
集合{}
}
公共窗口1()
{
初始化组件();
this.Loaded+=新路由EventHandler(Window1\u已加载);
this.unload+=新的路由EventHandler(Window1\u unload);
}
无效窗口1_已卸载(对象发送器,路由目标e)
{
//_fl=新的FijiLauncherControl();
_fl.IjmFinished-=新动作(FlFinished);
这是。_statusTimer.Stop();
//抛出新的NotImplementedException();
}
无效窗口1_已加载(对象发送器,路由目标e)
{
_fl=新的FijiLauncherControl();
_fl.IjmFinished+=新动作(FlFinished);
此。_statusTimer=new System.Windows.Forms.Timer();//每秒读取日志4次
这。_statusTimer.Interval=125;
此._statusTimer.Tick+=新事件处理程序(_statusTimer_Tick);
IjmFinished=“0”;
//抛出新的NotImplementedException();
}
已完成作废(布尔值)
{
//System.Windows.MessageBox.Show(System.Windows.Application.Current.MainWindow,“完成”);
System.Media.SystemSounds.Beep.Play();
}
void _statusTimer_Tick(对象发送方、事件参数e)
{
尝试
{
//如果(_fl.ProcessFinished)
//{
//_statusTimer.Stop();
//System.Windows.MessageBox.Show(System.Windows.Application.Current.MainWindow,“完成”);
////System.Windows.MessageBox.Show(“进程已完成”);
//}
}
捕获(例外情况除外)
{
}
}      
私有无效FijiLaucherButton_单击(对象发送者,路由目标e)
{         
_statusTimer.Start();
_fl.启动斐济();
}
私有void bOpenFijiDialog_单击(对象发送方,路由目标)
{
//创建“打开文件”对话框的实例。
OpenFileDialog openFijiDlg=新建OpenFileDialog();
流myStream=null;
//设置过滤器选项和过滤器索引。
openFijiDlg.Filter=“应用程序(.exe)|*.exe |所有文件(*.*)|*.”;
openFijiDlg.FilterIndex=1;
openFijiDlg.Multiselect=false;
if(openFijiDlg.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
尝试
{
if((myStream=openFijiDlg.OpenFile())!=null)
{
使用(myStream)
{
//在此处插入代码以读取流。
_fl.FijiExeFile=openFijiDlg.FileName;
}
}
}
捕获(例外情况除外)
{
System.Windows.Forms.MessageBox.Show(“错误:无法从磁盘读取斐济应用程序文件。原始错误:“+ex.Message”);
}
}
}
私有void bOpenIjmFileDialog_单击(对象发送方,路由目标)
{
//创建“打开文件”对话框的实例。
OpenFileDialog openIjmDlg=新建OpenFileDialog();
流myStream=null;
//设置过滤器选项和过滤器索引。
openIjmDlg.Filter=“ImageJ宏(.ijm)|*.ijm |所有文件(*.*)|*.”;
openIjmDlg.FilterIndex=1;
openIjmDlg.Multiselect=false;
if(openIjmDlg.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
尝试
{
if((myStream=openIjmDlg.OpenFile())!=null)
{
使用(myStream)
{
//在此处插入代码以读取流。
_fl.IjmFile=openIjmDlg.FileName;
}
}
}
捕获(例外情况除外)
{
System.Windows.Forms.MessageBox.Show(“错误:无法从磁盘读取ijm文件。原始错误:“+ex.Message”);
}
}
}
私人无效记录未检查(o
<Window x:Class="FijiLauncherTester.Window1"        
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local ="clr-namespace:FijiLauncherTester"
    Title="Window1" Height="370" Width="600">

    <Window.Resources>
        <local:BoolToValueConverter x:Key="IjmFinishedStatusConverter" />       
    </Window.Resources>

    <Grid>
        <Button Content="Launch Fiji" Click="FijiLaucherButton_Click" Margin="79,0,79,31" Height="30" VerticalAlignment="Bottom">
        </Button>
        <Button x:Name="bOpenFijiDialog" Content="Open fiji"
                 Height="30" Width="90" Margin="0,50,147,0"
                 HorizontalAlignment="Right" VerticalAlignment="Top" 
                 Click="bOpenFijiDialog_Click" />

        <TextBox x:Name="tbFiji" Text="Fiji_x64 Location"
                 Height="30" Width="300" Margin="10,50"
                 HorizontalAlignment="Left" VerticalAlignment="Top" 
                 Background="Beige" />

        <Button x:Name="bOpenIjmDialog" Content="Open Ijm"
                 Height="30" Width="90" Margin="0,124,147,0"
                 HorizontalAlignment="Right" VerticalAlignment="Top" 
                 Click="bOpenIjmFileDialog_Click" />

        <TextBox x:Name="tbIjm" Text="Ijm Location"
                 Height="30" Margin="10,124,268,0" VerticalAlignment="Top" 
                 Background="Beige" />

        <Label Content="Logging?"
                 Height="30" Width="88" Margin="10,0,0,131"
                 HorizontalAlignment="Left" VerticalAlignment="Bottom" />
        <RadioButton Height="16" HorizontalAlignment="Left" Margin="160,0,0,140" Name="LogiingYes" VerticalAlignment="Bottom" Width="120" Checked="LoggingYes_Checked">Yes</RadioButton>
        <RadioButton Height="16" HorizontalAlignment="Right" Margin="0,0,166,140" Name="LogiingNo" VerticalAlignment="Bottom" Width="120" Checked="LoggingNo_Checked">No</RadioButton>
        <Label Height="30" Width="50" Content="Done?" HorizontalAlignment="Left" Margin="21,0,0,82" VerticalAlignment="Bottom" />
        <Label Margin="120,0,0,82" Height="30" VerticalAlignment="Bottom" Content="ffff" HorizontalAlignment="Left" Width="80" />   
    </Grid>
</Window>
using System;
using System.Collections.Generic;
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 FijiLauncher;
using System.Windows.Forms;
using System.IO;

namespace FijiLauncherTester
{    

    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        private FijiLauncherControl _fl;
        private System.Windows.Forms.Timer _statusTimer;

        public string IjmFinished
        {
            get { return Convert.ToString(_fl.IjmFinished);}
            set { }
        }

        public Window1()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(Window1_Loaded);
            this.Unloaded += new RoutedEventHandler(Window1_Unloaded);


        }

        void Window1_Unloaded(object sender, RoutedEventArgs e)
        {

            //_fl = new FijiLauncherControl();
            _fl.IjmFinished -= new Action<bool>(FlFinished);

            this._statusTimer.Stop();

           // throw new NotImplementedException();
        }

        void Window1_Loaded(object sender, RoutedEventArgs e)
        {

            _fl = new FijiLauncherControl();
            _fl.IjmFinished += new Action<bool>(FlFinished);

            this._statusTimer = new System.Windows.Forms.Timer();  // read log 4 times per sec 
            this._statusTimer.Interval = 125;
            this._statusTimer.Tick += new EventHandler(_statusTimer_Tick);
            IjmFinished = "0";
            //throw new NotImplementedException();
        }


        void FlFinished(bool val)
        {
            //System.Windows.MessageBox.Show(System.Windows.Application.Current.MainWindow, "Finished");
            System.Media.SystemSounds.Beep.Play();
        }

        void _statusTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                //if (_fl.ProcessFinished)
                //{
                //    _statusTimer.Stop();

                //    System.Windows.MessageBox.Show(System.Windows.Application.Current.MainWindow, "Finished");
                //    //System.Windows.MessageBox.Show("Process is finished");

                //}
            }
            catch (Exception ex)
            {
            }
        }      

        private void FijiLaucherButton_Click(object sender, RoutedEventArgs e)
        {         
            _statusTimer.Start();           
            _fl.LaunchFiji();

        }

        private void bOpenFijiDialog_Click(object sender, RoutedEventArgs e)
        {
             // Create an instance of the open file dialog box.
            OpenFileDialog openFijiDlg = new OpenFileDialog();
            Stream myStream = null;

            // Set filter options and filter index.
            openFijiDlg.Filter = "Application (.exe)|*.exe|All Files (*.*)|*.*";
            openFijiDlg.FilterIndex = 1;

            openFijiDlg.Multiselect = false;

            if (openFijiDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFijiDlg.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            // Insert code to read the stream here.
                            _fl.FijiExeFile = openFijiDlg.FileName;
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show("Error: Could not read fiji application file from disk. Original error: " + ex.Message);
                }
            }
        }

        private void bOpenIjmFileDialog_Click(object sender, RoutedEventArgs e)
        {

            // Create an instance of the open file dialog box.
            OpenFileDialog openIjmDlg = new OpenFileDialog();
            Stream myStream = null;

            // Set filter options and filter index.
            openIjmDlg.Filter = "ImageJ Macro (.ijm)|*.ijm|All Files (*.*)|*.*";
            openIjmDlg.FilterIndex = 1;

            openIjmDlg.Multiselect = false;

            if (openIjmDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    if ((myStream = openIjmDlg.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            // Insert code to read the stream here.
                            _fl.IjmFile = openIjmDlg.FileName;
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show("Error: Could not read ijm file from disk. Original error: " + ex.Message);
                }
            }

        }

        private void LoggingNo_Checked(object sender, RoutedEventArgs e)
        {
            _fl.IsLogOn = false;
        }

        private void LoggingYes_Checked(object sender, RoutedEventArgs e)
        {
            _fl.IsLogOn = true;
        }
    }


    public class BoolToValueConverter<T> : IValueConverter
    {
        public T FalseValue { get; set; }
        public T TrueValue { get; set; }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return FalseValue;
            else
                return (bool)value ? TrueValue : FalseValue;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value != null ? value.Equals(TrueValue) : false;
        }
    }
}
public class BoolToValueConverter : IValueConverter
{
    // Note that you're never setting this!
    public object FalseValue { get; set; }
    public object TrueValue { get; set; }

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value == null)
            return FalseValue;
        else
            return (bool)value ? TrueValue : FalseValue;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return value != null ? value.Equals(TrueValue) : false;
    }
}