WPF ---- xmal 解析器没有办法解析类的TypeConverter
2014-06-30 11:05
148 查看
xmal 解析器没有办法解析类的TypeConverter.代码如下
页面代码:
<Window x:Class="WpfApplication_xmln.Windows.ConvertWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:codes="clr-namespace:WpfApplication_xmln.Codes"
Title="ConvertWindow" Height="300" Width="300">
<Window.Resources>
<codes:Human x:Key="scHuman" Name="NiNi" Child="HeHe"></codes:Human>
</Window.Resources>
<Grid>
<Button Margin="50,50,50,50" Click="Button_Click" Content="this is the button" Background="Violet"></Button>
</Grid>
</Window>
后台代码:
[TypeConverterAttribute(typeof(StringToHumanTypeConvert))]
class Human
{
public string Name { get; set; }
public Human Child { get; set; }
}
class StringToHumanTypeConvert : TypeConverter// using System.System.ComponentModel;
{
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value != null)
{
Human h = new Human();
h.Name = value.ToString();
return h;
}
return base.ConvertFrom(context, culture, value);
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Human h = this.FindResource("scHuman") as Human;
MessageBox.Show(h.Child.Name);
}
错误1“Human”的 TypeConverter 不支持从字符串进行转换。这个问题到目前为止还没有解决。但是程序是可正常运行的。没有运行问题。
页面代码:
<Window x:Class="WpfApplication_xmln.Windows.ConvertWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:codes="clr-namespace:WpfApplication_xmln.Codes"
Title="ConvertWindow" Height="300" Width="300">
<Window.Resources>
<codes:Human x:Key="scHuman" Name="NiNi" Child="HeHe"></codes:Human>
</Window.Resources>
<Grid>
<Button Margin="50,50,50,50" Click="Button_Click" Content="this is the button" Background="Violet"></Button>
</Grid>
</Window>
后台代码:
[TypeConverterAttribute(typeof(StringToHumanTypeConvert))]
class Human
{
public string Name { get; set; }
public Human Child { get; set; }
}
class StringToHumanTypeConvert : TypeConverter// using System.System.ComponentModel;
{
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value != null)
{
Human h = new Human();
h.Name = value.ToString();
return h;
}
return base.ConvertFrom(context, culture, value);
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Human h = this.FindResource("scHuman") as Human;
MessageBox.Show(h.Child.Name);
}
错误1“Human”的 TypeConverter 不支持从字符串进行转换。这个问题到目前为止还没有解决。但是程序是可正常运行的。没有运行问题。
相关文章推荐
- 安装完Apache和PHP之后访问PHP文件页面提示下载而没有解析 解决办法
- thymeleaf模板对没有结束符的HTML5标签解析出错的解决办法
- 域名进入黑名单,备案暂时没有通过办法之HOST域名解析
- spring-boot thymeleaf对没有结束符的HTML5标签解析出错解决办法
- thymeleaf解析html5标签出错(没有结束符)解决办法
- spring-boot thymeleaf对没有结束符的HTML5标签解析出错解决办法
- thymeleaf模板对没有结束符的HTML5标签解析出错的解决办法
- spring-boot thymeleaf对没有结束符的HTML5标签解析出错解决办法
- Android Json解析中如何解析没有key的解析办法
- wpf arcgis engine 当前没有或未启用Spatial Analyst许可解决办法
- thymeleaf模板对没有结束符的HTML5标签解析出错的解决办法
- eclipse不能解析导入HttpServletRequest解决办法一
- IIS无法解析asp文件的原因分析及解决办法
- 谋杀失败!可以杀掉Notepad.exe这样的进程,却对CcmExec.exe这个进程没有办法!
- vc++中没有属性和方法的提示的解决办法
- Eclipse 没有响应 JVM terminated. Exit code=1073807364 错误 卡住 等怪问题怪现象[解决办法]
- 在ArcGIS Server中用regsvcs注册服务器端扩展的动态链接库时候,出现没有强名称错误的解决办法
- MSDN两天没有办法使用, 提示"当前子集中没有该选项,请选择其他子集",问题解决了
- 没有限制IIS连接,出现“Service Unavailable”的原因及解决办法
- 运行cl.exe编译发生:没有找到 mspdb80.dll 的解决办法