首页 > 解决方案 > WPF 设计器问题:XDG0008 名称“NumericTextBoxConvertor”在命名空间“clr-namespace:PulserTester.Convertors”中不存在

问题描述

我有一个错误,让我看不到我的设计师.. 但我在构建时没有错误,我的程序运行良好,没有问题

我试图:

没有任何帮助。我不知道我还能做些什么来解决它。

我必须尝试在这里查看,即使在重新启动 Visual Studio 后也没有为我工作,重新构建了解决方案

名称 <...> 不存在于命名空间 clr-namespace <...>

这是我的错误:

在此处输入图像描述

这是 Xaml 文件:

<Window x:Class="PulserTester.windows.ConfigPage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:PulserTester.windows"
        xmlns:Convertors="clr-namespace:PulserTester.Convertors"
        mc:Ignorable="d" 
             d:DesignHeight="575.068" Width="500">
    <Window.Resources>
        <Convertors:NumericTextBoxConvertor x:Key="NumericTextBoxConvertor" />
    </Window.Resources>
    <Grid Background="White">
        <StackPanel>
            <StackPanel Margin="5">
                <TextBlock HorizontalAlignment="Right">שם הפולסר</TextBlock>
                <TextBox HorizontalAlignment="Right" MinWidth="100" Text="{Binding PulserName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></TextBox>
            </StackPanel>

            <StackPanel Margin="5">
                <TextBlock HorizontalAlignment="Right">האם להציג הודעה במצב של כישלון</TextBlock>
                <CheckBox  HorizontalAlignment="Right" IsChecked="{Binding FailQuestion,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></CheckBox>
            </StackPanel>

            <StackPanel Margin="5">
                <TextBlock HorizontalAlignment="Right">האם לאפשר בדיקת כיול</TextBlock>
                <CheckBox  HorizontalAlignment="Right" IsChecked="{Binding CalibrationOption,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></CheckBox>
            </StackPanel>

            <StackPanel Margin="5">
                <TextBlock HorizontalAlignment="Right">סגנון הבדיקה</TextBlock>
                <ComboBox HorizontalAlignment="Right" Width="213"
                          ItemsSource="{Binding CheckStyles.Keys}"
                          SelectedItem="{Binding CheckStyleSelected,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                          ></ComboBox>
            </StackPanel>

            <StackPanel Margin="5">
                <TextBlock HorizontalAlignment="Right">מספר המפעל</TextBlock>
                <ComboBox HorizontalAlignment="Right" Width="213"
                          ItemsSource="{Binding FactoriesNumbers}"
                          SelectedItem="{Binding FactorySelected,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                          ></ComboBox>
            </StackPanel>

            <StackPanel Margin="5">
                <TextBlock HorizontalAlignment="Right">תדירות השמירה בבידקות</TextBlock>
                <TextBox HorizontalAlignment="Right" MinWidth="100" Text="{Binding SaveBatteryFreq,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Converter={StaticResource NumericTextBoxConvertor}}"></TextBox>
            </StackPanel>

            <StackPanel Margin="5">
                <TextBlock HorizontalAlignment="Right">לאפשר גבולות סטטסיטיים</TextBlock>
                <CheckBox  HorizontalAlignment="Right" IsChecked="{Binding AllowUsingStatistic, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
            </StackPanel>

            <StackPanel Margin="5">
                <TextBlock HorizontalAlignment="Right">מספר התאים לתחילת הסטטסיטיקה</TextBlock>
                <TextBox HorizontalAlignment="Right" MinWidth="100" Text="{Binding NumberOfCellToStartTheStatistics,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Converter={ StaticResource  NumericTextBoxConvertor}}"></TextBox>

            </StackPanel>

            <StackPanel Margin="5">
                <TextBlock HorizontalAlignment="Right">מספר התאים להתחול הסטטיסטיקה מחדש</TextBlock>
                <TextBox HorizontalAlignment="Right" MinWidth="100" Text="{Binding NumberOfCellToRestartTheStatistics,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Converter={ StaticResource  NumericTextBoxConvertor}}"></TextBox>
            </StackPanel>

            <StackPanel Margin="5">
                <Button Command="{Binding Path=SaveCommand}">bb</Button>
            </StackPanel>

           
        </StackPanel>
    </Grid>
</Window>

这是我的转换器:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace PulserTester.Convertors
{
    public class NumericTextBoxConvertor : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value.ToString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string val = value.ToString();

            long ret = long.TryParse(new string(val.Where(char.IsDigit).ToArray()), out long result) ? result : 0;
            if (ret > int.MaxValue)
            {
                ret = int.MaxValue;
            }
            return ret;
        }
    }
}

标签: c#wpfxamlmvvm

解决方案


我只想重申Bradley Uffner在上述评论中提到的解决方案。

  1. 关闭 Visual Studio

  2. 删除隐藏.vs文件夹

  3. 打开 Visual Studio 并重建您的项目

请记住,这是一个非常普遍的错误,有多种原因和解决方案,因此这可能对您不起作用,但绝对值得一试,因为我知道它过去曾多次对我有用。


推荐阅读