【发布时间】:2015-09-01 08:38:52
【问题描述】:
我有一个问题,我有一个列表视图,我们称之为 ListView1,它是在从 Azure 同步后从本地存储动态填充的。
现在我在从项目点击中选择和获取信息时遇到问题。
当列表视图上有项目点击时,我需要获取四种不同类型的信息并将其传递给弹出窗口。
//This is the way the List is Created
string DB_PATH = Path.Combine(ApplicationData.Current.LocalFolder.Path, "my.db");
public async void CreateList ()
{
await AzureWebService.Instance.InitLocalStoreAsync(DB_PATH);
var t = await AzureWebService.Instance.GetListItems(); //GET THE OG LIST
var list = new ObservableCollection<winMerchant>(); //create a new list of Names, (with the BitmapImage Field )
foreach (var f in t)
{
var m = new winDirectory(); //give the customized merchant object, the same VALUES as the ACTUAL mercahnt object
m.MyName1 = f.MyName1;
m.MyName2 = f.MyName2;
m.MyNumber = f.MyNumber; //int
m.MyPic = ImageHelper.Base64StringToBitmap(f.MyPic); //CUSTOM PART ==> Take the newly defined BitmapImage (wMyPic) and convert the Pic string into it
list.Add(m); //add the new People into a list
}
MyList.ItemsSource = list;
}
这就是 xaml
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Stretch">
<Image Source="{Binding wPic}" Width="75" Height="75" />
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<TextBlock Text="{Binding wMyName1}" />
<TextBlock Text="{Binding wMyName2}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
助手类
class winMerchant: Contacts
{
public BitmapImage wPic { get; set; }
public int wMyNumber { get; set; }
public string wMyName1 { get; set; }
public string wMyName2 { get; set; }
}
数字应在点击时传递给浮出控件... 任何帮助都感激不尽!
【问题讨论】:
标签: c# listview windows-phone-8.1