我实现了LongListSelector
控制器而不是ListView
控制器,因为我使用的是Windows Phone Silverlight应用程序。
我想将Name绑定到Button
控制器。但我无法完成它。
<Button Name="{Binding Name}" Content="Download" Grid.Row="2" Grid.Column="1" Click="Button_Click_1" Width="170" Height="70" Background="#b3c833"></Button>
TextBox
和Image
LongListSelector
控制器成功了。
任何建议都将不胜感激。
public class Station
{
// private string _stationName;
private string _stationName;
// private BitmapImage bm = new BitmapImage(new Uri(@"Image/Darktheme.png", UriKind.RelativeOrAbsolute));
private Uri bm;
private string btnop;
public Uri ImageUrl
{
get { return bm; }
set { bm = value; }
}
public string Name
{
get { return _stationName; }
set { _stationName = value; }
}
public string btnop1
{
get { return btnop; }
set {
btnop = value; }
}
public Station( Uri bm,string station, string ty)
{
this.Name = station;
this.ImageUrl = bm;
this.btnop1 = ty;
}
}
ObservableCollection<Station> trainStations = new ObservableCollection<Station>();
trainStations.Add(new Station(new Uri("Assets/pdfdoc.png", UriKind.RelativeOrAbsolute),d, word));
答案 0 :(得分:0)
根据MSDN使用FrameworkElement.Tag
属性。
FrameworkElement.Tag获取或设置一个可用于存储有关此元素的自定义信息的任意对象值。
这{{}}}明确指出。绑定只能进行DependencyProperty
。它不适用于x:Name
。
如果要遍历LongListSelector
,可以将Name
成员绑定到Tag
属性。