문제

I want to populate my ListPicker with the entries that I have in a database named FriendsClass.

My XAML:

<toolkit:ListPicker x:Name="friendPicker" SelectionMode="Multiple" Margin="129,283,10,119" BorderBrush="#FF8DCDC1" IsEnabled="False">
    <toolkit:ListPicker.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Name}"/>
        </DataTemplate>
    </toolkit:ListPicker.ItemTemplate>
</toolkit:ListPicker>

My CS:

 SplitDataContext db = new SplitDataContext("Data Source=isostore:/S.sdf");

 List<FriendsClass> source = new List<FriendsClass>();
 var friendQuery = from friend in db.Friends select friend;

 foreach (var friend in friendQuery)
 {
     source.Add(new FriendsClass(){Name = friend.Name});
 }
 this.friendPicker.ItemsSource = source;

When I run my app, the ListPicker displays "Split.ViewModels.FriendsClass" instead of the name itself.

Here is my list of friends enter image description here

But here is what appears on my ListPicker enter image description here

What have I been missing? I've tried putting a ToList() function on my query but it's still the same. When I bind my ListPicker to my Friends table in the XAML, absolutely nothing appears.

Thank you very much for your help.

도움이 되었습니까?

해결책

Figured it out: I used FullModeItemTemplate instead of the regular ItemTemplate in my xaml.

<toolkit:ListPicker x:Name="friendPicker" SelectionMode="Multiple" Margin="129,283,10,119" BorderBrush="#FF8DCDC1" IsEnabled="False" >
    <toolkit:ListPicker.FullModeItemTemplate>
        <DataTemplate>             
            <TextBlock Text="{Binding Name}"/>
        </DataTemplate>
    </toolkit:ListPicker.FullModeItemTemplate>
</toolkit:ListPicker>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top