Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 与WP7.5上的匿名对象绑定_C#_Silverlight_Windows Phone 7_Data Binding - Fatal编程技术网

C# 与WP7.5上的匿名对象绑定

C# 与WP7.5上的匿名对象绑定,c#,silverlight,windows-phone-7,data-binding,C#,Silverlight,Windows Phone 7,Data Binding,在WP7.5上,我创建了如下数据上下文: this.DataContext = new { One = listOne, Two = listTwo}; 在我的XAML代码中,我尝试了以下方法: <TextBlock Text="{Binding listOne.m_strTypeTiers}" Style="{StaticResource PhoneTextNormalStyle}" /> <TextBlock Text="{Binding listTwo.m_strTyp

在WP7.5上,我创建了如下数据上下文:

this.DataContext = new { One = listOne, Two = listTwo};
在我的XAML代码中,我尝试了以下方法:

<TextBlock Text="{Binding listOne.m_strTypeTiers}" Style="{StaticResource PhoneTextNormalStyle}" />
<TextBlock Text="{Binding listTwo.m_strTypeTiers}" Style="{StaticResource PhoneTextNormalStyle}" />


我的文本框是空的。我认为我的绑定语法有一个错误。

我认为您正在寻找
{binding One.m_strTypeTiers}

但这取决于列表一和列表二是什么。这些类是否具有名为m_strTypeTiers的属性?如果m_strTypeTiers是一个字段,那么您将无法对其进行数据绑定。数据绑定仅适用于属性()


更新
哎呀。我在考虑桌面应用程序的WPF。这非常相似,但在一些重要方面有所不同。我认为你运气不好——你需要定义一个具体的类

您可能会发现这篇文章在将来很有帮助:

(……并不是说它会帮助你解决这个问题)

这是一个类,它们是属性:在这种情况下,你可能想考虑在微软上阅读。谢谢这个链接,但是,我试着{绑定一个。MyStruthPueServ}没有成功:(此引用的是什么?您可能还需要检查输出中的WPF绑定警告消息。我的xaml文件名为page1.xaml,这在我的cs页面上,名为page1.xaml.cs。这是page1.xaml.cs实例。重要的是,如果我使用“this.datacontext=ListOne”,则绑定正常。我的问题来自{one=ListOne,two=listwo}。