c# - WPF 设计器问题:XDG0008 名称“NumericTextBoxConvertor”在命名空间“clr-namespace:PulserTester.Convertors”中不存在
问题描述
我有一个错误,让我看不到我的设计师.. 但我在构建时没有错误,我的程序运行良好,没有问题
我试图:
- 清理和重建
- 更新 Visual Studio
- 修复 Visual Studio
- 重启我的电脑
没有任何帮助。我不知道我还能做些什么来解决它。
我必须尝试在这里查看,即使在重新启动 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;
}
}
}
解决方案
我只想重申Bradley Uffner在上述评论中提到的解决方案。
关闭 Visual Studio
删除隐藏
.vs
文件夹打开 Visual Studio 并重建您的项目
请记住,这是一个非常普遍的错误,有多种原因和解决方案,因此这可能对您不起作用,但绝对值得一试,因为我知道它过去曾多次对我有用。
推荐阅读
- sql - 如何提高 SQL Server 中合并语句的性能
- timer - 如果在Arduino中点亮60秒,如何发出蜂鸣器?
- node.js - Node.js bcrypt比较问题只返回false
- .net-core - dotnet-ef 工具向后兼容?
- php - WordPress 插件:挂钩到 post_row_actions 函数自定义 PHP 的内容
- typescript - 使用 TS 文字类型,获取匹配多个模式与字符串文字联合的字符串的最直接方法是什么?
- android - mipmap 启动器图标的别名
- python - Jupyter notebook / Ipython 使用 __getattr__ 自动完成
- string - 从字符串中删除换行符?
- java - synchronized(hashmap.get(data)) 线程安全吗?