Databinding List<Object> WindowsPhone

2019-08-28 01:19发布

问题:

I would like to improve my productivity to use the correct design. So I add a folder SampleData and a file RestaurantsSampleData.xaml The structure of this file defines :

 xmlns:vm="clr-namespace:GeolocationTest.ViewModels">
<vm:MainViewModel.Pois>
    <vm:Poi Id="1" Adresse="20 rue de vinci, 33700 merignac" Name="MacDonald" />
    <vm:Poi Id="2" Adresse="20 rue de vinci, 33700 merignac" Name="MacDonald"/>
    <vm:Poi Id="3" Adresse="20 rue de vinci, 33700 merignac" Name="MacDonald"/>
    <vm:Poi Id="4" Adresse="20 rue de vinci, 33700 merignac" Name="MacDonald"/>
    <vm:Poi Id="5" Adresse="20 rue de vinci, 33700 merignac" Name="MacDonald"/>
    <vm:Poi Id="6" Adresse="20 rue de vinci, 33700 merignac" Name="MacDonald"/>
    <vm:Poi Id="7" Adresse="20 rue de vinci, 33700 merignac" Name="MacDonald"/>
    <vm:Poi Id="8" Adresse="20 rue de vinci, 33700 merignac" Name="MacDonald"/>
    <vm:Poi Id="9" Adresse="20 rue de vinci, 33700 merignac" Name="MacDonald"/>
    <vm:Poi Id="10" Adresse="20 rue de vinci, 33700 merignac" Name="MacDonald" />
</vm:MainViewModel.Pois>

And my class Pois is

   public class PoiDetail : PoiBase
{
    public String FormattedAddress { get; set; }        
    public String FormattedPhoneNumber { get; set; }
    public String Icon { get; set; }
    public List<Review> Reviews { get; set; }
    public double Latitude { get; set; }
    public double Longitude { get; set; }
}

I would like to add a list in my RestaurantsSampleData.xml to permit to display in the designer of visual studio. Currently I don't find any way to do it and I loose many time between build the application, check the design and modify it. It will more effective to use sample and after plug the real data.

回答1:

Use blend to create your sample data if you have it with your copy of Visual Studio 2013

  1. Create a new windows phone silver light project
  2. Create new Sample Data

Described in this link...

http://msdn.microsoft.com/en-us/library/ee341450(v=expression.40).aspx

  1. Drag and drop the Collection onto the mainpaige.xaml

Change the data context of your list when you run the application to see the actual data