【发布时间】:2015-08-19 13:10:37
【问题描述】:
WPFConverternamespace 有问题。
以下是说明:
local:BoolToColor 的“名称在命名空间中不存在”。
XAML:
<Window x:Class="TFE_WPF.View.FicheClient"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TFE_WPF.View"
Title="FicheClient" Height="588" Width="663">
<Window.Resources>
<local:BoolToColor x:Key="SColor"></local:BoolToColor>
</Window.Resources>
XAML 背后的代码:
namespace TFE_WPF.View
{
public partial class FicheClient : Window
{
public FicheClient()
{
InitializeComponent();
this.DataContext = new FicheClientViewModel();
}
}
public class BoolToColor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (bool)value ? new SolidColorBrush(Colors.GreenYellow) : new SolidColorBrush(Colors.DarkRed);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
这种代码方法有什么问题?我清理了解决方案并重建它,但遇到了同样的错误。
【问题讨论】:
-
您的项目是否构建?当出现错误并且项目无法编译时,我遇到了这个问题。
-
您是否也尝试过清理和重建解决方案?
标签: c# wpf converters