【发布时间】:2013-09-16 22:02:28
【问题描述】:
我在 Windows Phone 中进行绑定时遇到问题。希望你能帮助我。
我在 App.xaml 中有以下数据模板:
<Application.Resources><DataTemplate><TextBox Name="txt1"/><TextBox Name="txt2"/></DataTemplate></Application.Resources>
我有一个带有以下数据模板的列表框:
<ListBox><ListBox.ItemTemplate><DataTemplate><TextBox Name="txt1"/><TextBox Name="txt2"/></DataTemplate><ListBox.ItemTemplate><ListBox>
ListBox 在 ItemsSource 属性中接收以下类:
public class Product
{
private int _id;
public int Id
{
get { return _id; }
set { _id = value; }
}
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
}
有没有办法将 Resources.TextBox.Text 属性与 ListBoxItem 的对象绑定,例如...
<Application.Resources><TextBox Name="txt1" Text={Binding ElementName=ListBox, Path=SelectedItem.Product.Name}/></Application.Resources>
【问题讨论】:
标签: windows-phone-7 binding windows-phone-8 windows-phone