Windows Phone 8.1 LongListSelector问题与按钮

时间:2015-04-24 11:21:47

标签: c# windows-phone-8 longlistselector

我实现了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>

TextBoxImage 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));   

1 个答案:

答案 0 :(得分:0)

根据MSDN使用FrameworkElement.Tag属性。

FrameworkElement.Tag获取或设置一个可用于存储有关此元素的自定义信息的任意对象值。

这{{}}}明确指出。绑定只能进行DependencyProperty。它不适用于x:Name

如果要遍历LongListSelector,可以将Name成员绑定到Tag属性。