2014-10-30 2 views
0

내가 예를 날짜로 수평으로 내 해당 페이지에서 데이터베이스에서 6 개 값을 보여 드리고자 | 시간 | 층 | 지역 | 위도 | 경도 그러나 페이지는 데이터를 보여줍니다 | 시간 | 바닥을 | 지역 와 위도를 표시하지 않고 아래 경도 내 XAML 코드XAML 윈도우 폰 8

<Grid x:Name="LayoutRoot" Background="Transparent"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

    <!--TitlePanel contains the name of the application and page title--> 
    <StackPanel Grid.Row="0" Margin="12,17,0,28"> 
     <TextBlock Text="Smart Parking" Style="{StaticResource PhoneTextNormalStyle}"/> 
     <TextBlock Text="History" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> 
    </StackPanel> 
    <!--ContentPanel - place additional content here--> 
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
     <ListBox x:Name="ListData"> 
      <ListBox.ItemTemplate> 
       <DataTemplate> 
          <StackPanel Orientation="Horizontal"> 
          <TextBlock x:Name= "DateTxt" Text="{Binding Date}" TextWrapping="Wrap" /> 
          <TextBlock x:Name= "TimeTxt" Text="{Binding Time}" TextWrapping="Wrap" /> 
          <TextBlock x:Name= "ZoneTxt" Text="{Binding Zone}" TextWrapping="Wrap"/> 
          <TextBlock x:Name= "FloorTxt" Text="{Binding Floor}" TextWrapping="Wrap"/> 
          <TextBlock x:Name= "LatTxt" Text="{Binding location_latitude}" TextWrapping="Wrap" /> 
          <TextBlock x:Name= "LongTxt" Text="{Binding location_longitude}" TextWrapping="Wrap" /> 
         </StackPanel> 
       </DataTemplate> 
      </ListBox.ItemTemplate> 
     </ListBox> 
    </Grid> 
</Grid> 

사람은 내가 그것을 그것을 개선 또는 수정 도와 주실 수 있습니까?

목록 itmesource에 대한 뒤에 코드는 여기에 아래의 모든 주요 기능

public class DbHelper 
{ 

    SQLiteConnection dbConn; 

    public async Task<bool> onCreate(string DB_PATH) 
    { 
     try 
     { 
      if (!CheckFileExists(DB_PATH).Result) 
      { 
       using (dbConn = new SQLiteConnection(DB_PATH)) 
       { 
        dbConn.CreateTable<historyTableSQlite>(); 
       } 
      } 
      return true; 
     } 
     catch 
     { 
      return false; 
     } 
    } 


    private async Task<bool> CheckFileExists(string fileName) 
    { 
     try 
     { 
      var store = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync(fileName); 
      return true; 
     } 
     catch 
     { 
      return false; 
     } 
    } 

    //retrieve all list from the database 
    public ObservableCollection<historyTableSQlite> ReadHistory() 
    { 
     using (var dbConn = new SQLiteConnection(App.DB_PATH)) 
     { 
      List<historyTableSQlite> myCollection = dbConn.Table<historyTableSQlite>().ToList<historyTableSQlite>(); 
      ObservableCollection<historyTableSQlite> HistoryList = new ObservableCollection<historyTableSQlite>(myCollection); 
      return HistoryList; 
     } 
    } 

    // Insert the new info in the histrorytablesqlite table. 
    public void Insert(historyTableSQlite newcontact) 
    { 
     using (var dbConn = new SQLiteConnection(App.DB_PATH)) 
     { 
      dbConn.RunInTransaction(() => 
      { 
       dbConn.Insert(newcontact); 
      }); 
     } 
    } 

    public void AddInfo() 
    { 

     DbHelper Db_helper = new DbHelper(); 
     Db_helper.Insert((new historyTableSQlite 
     { 
      Date = DateTime.Now.ToShortDateString(), 
      Time = DateTime.Now.ToShortTimeString(), 
      Zone = "PST", 
      Floor = "10th Floor", 
      latitude = 35.45112, 
      longtitude = -115.42622 
     })); 

    } 


} 

마지막 클래스 DBhelper 클래스는 값

public class historyTableSQlite : INotifyPropertyChanged 
{ 
    [SQLite.PrimaryKey, SQLite.AutoIncrement] 

    public int Id { get; set; } 
    private int idvalue; 

    private string dateValue = string.Empty; 

    public string Date { 
     get { return this.dateValue; } 
     set 
     { 
      if (value != this.dateValue) 
      { 
       this.dateValue = value; 
       NotifyPropertyChanged("Date"); 
      } 
     } 
    } 


    private string timeValue = string.Empty; 
    public string Time 
    { 
     get { return this.timeValue; } 
     set 
     { 
      if (value != this.timeValue) 
      { 
       this.timeValue = value; 
       NotifyPropertyChanged("Time"); 
      } 
     } 
    } 

    private string floorValue = string.Empty; 
    public string Floor 
    { 
     get { return this.floorValue; } 
     set 
     { 
      if (value != this.floorValue) 
      { 
       this.floorValue = value; 
       NotifyPropertyChanged("Floor"); 
      } 
     } 
    } 

    public string zoneValue; 
    public string Zone 
    { 
     get { return this.zoneValue; } 
     set 
     { 
      if (value != this.zoneValue) 
      { 
       this.zoneValue = value; 
       NotifyPropertyChanged("Zone"); 
      } 
     } 
    } 

    private double latValue; 
    public double latitude 
    { 
     get { return latValue; } 
     set 
     { 
      if (value != this.latValue) 
      { 
       this.latValue = value; 
       NotifyPropertyChanged("Latitude"); 
      } 
     } 
    } 

    private double lonValue; 
    public double longtitude 
    { 
     get { return this.lonValue; } 
     set 
     { 
      if (value != this.lonValue) 
      { 
       this.lonValue = value; 
       NotifyPropertyChanged("Longitude"); 
      } 
     } 
    } 

    // public string isMarkPoint { get; set; } 

    public historyTableSQlite() 
    { 

    } 

    public historyTableSQlite(string date,string time,string floor,string zone,double lat,double lng) 
    { 
     Date = date; 
     Time = time; 
     Floor = floor; 
     Zone = zone; 
     latitude = lat; 
     longtitude = lng; 
    } 
    public event PropertyChangedEventHandler PropertyChanged; 

    private void NotifyPropertyChanged(String info) 
    { 
     if (PropertyChanged != null) 
     { 
      PropertyChanged(this, new PropertyChangedEventArgs(info)); 
     } 
    } 
} 
을 유지하기위한 것입니다

public partial class History : PhoneApplicationPage 
{ 





    // string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite"); 
    ObservableCollection<historyTableSQlite> DB_HistoryList = new ObservableCollection<historyTableSQlite>(); 
    DbHelper add = new DbHelper(); 
    public History() 
    { 

     InitializeComponent(); 

    } 

    protected override void OnNavigatedTo(NavigationEventArgs e) 
    { 
     add.AddInfo(); 
     ReadHistoryList_Loaded(); 
    } 

    public void ReadHistoryList_Loaded() 
    { 
     ReadAllContactsList dbhistory = new ReadAllContactsList(); 
     DB_HistoryList = dbhistory.GetAllHistory();//Get all DB contacts 
     ListData.ItemsSource = DB_HistoryList.OrderByDescending(i => i.Id).ToList();//Latest contact ID can Display first 

    } 

아래 여기에있다

+0

ListData.ItemsSource는 무엇으로 설정되어 있습니까? 코드 숨김을 보여줄 수 있습니까? – bit

+0

@bit 예 질문에 따라 위 코드를 업데이트했습니다. 내 코드를 조사해 주셔서 감사합니다. –

답변

0

귀하의 텍스트 블록을 location_longitude에 바인딩하고 있는데 위치가 표시되지 않습니다. 경도 (또는 위도)를 코드 뒤에 표시합니다.

플러스, 당신은 당신의 LongitudeLatitude 선언에서

<TextBlock x:Name="LatTxt" Text="{Binding Latitude}" TextWrapping="Wrap" /> 
<TextBlock x:Name="LongTxt" Text="{Binding Longitude}" TextWrapping="Wrap" /> 

희망이 도움말로 된 본체를 결합하는

public double longtitude // Here change to Longitude 
    { 
     get { return this.lonValue; } 
     set 
     { 
      if (value != this.lonValue) 
      { 
       this.lonValue = value; 
       NotifyPropertyChanged("Longitude"); 
      } 
     } 
    } 

private double latValue; 
    public double latitude // Change to Latitude 
    { 
     get { return latValue; } 
     set 
     { 
      if (value != this.latValue) 
      { 
       this.latValue = value; 
       NotifyPropertyChanged("Latitude"); 
      } 
     } 
    } 

시도를 조금 철자가 있습니다.

+1

위도와 같습니다. 속성 이름은 NotifyPropertyChanged에 대한 인수, 즉 대문자'Latitude'와 같아야합니다. – Clemens

+0

예, 그에 따라 코드를 업데이트했습니다. 정확한 문장으로 업데이트하겠습니다. – Aymeric

+0

@Aymeric 정말 고마워요. 그것은 효과가있다! –