I have a problem reading sqlite, ie the data in the table can not be read (but the amount of data read), as shown below:
XAML:
<ListBox x:Name="dictionary" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="20" Text="{Binding Id}" Visibility="Collapsed"/>
<TextBlock FontSize="20" Text="{Binding Word}" FontWeight="SemiBold" Margin="30,0,0,0"/>
<TextBlock FontSize="20" Text="{Binding Translation}" FontWeight="SemiBold" Margin="30,0,0,0"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
note: The above XAML I used the word text = "Word" and the translation text = "Translation" to test whether the data on sqlite legible or not. Although the use of binding data remains unreadable
code:
public ObservableCollection<ind_dict> ReadIndo()
{
var sqlpath = System.IO.Path.Combine(Package.Current.InstalledLocation.Path, @"Assets\kamus.sqlite");
using (var dbConn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath))
{
List<ind_dict> myCollection = dbConn.Table<ind_dict>().ToList<ind_dict>();
ObservableCollection<ind_dict> indoList = new ObservableCollection<ind_dict>(myCollection);
dictionary.ItemsSource = indoList;
return indoList;
}
}
ind_dict class:
public class ind_dict
{
[SQLite.Net.Attributes.PrimaryKey]
public string Id { get; set; }
public string Word { get; set; }
public string Translation { get; set; }
public ind_dict(string word, string translation)
{
Word = word;
Translation = translation;
}
}
How to solve it?
Aucun commentaire:
Enregistrer un commentaire