我正在使用 SqlLite 数据库创建一个应用程序。我可以使用注册页面中的一些基本信息填充数据库,并在“登录”选项卡下仅显示该人的 ID(这目前用于测试目的)。我将如何通过单击删除按钮来删除数据库中的特定位置?这是我连接到我的数据库并使用它在列表视图下的页面上仅显示 Id 的 cs。
namespace SP
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class LoginPage : ContentPage
{
public LoginPage()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.FilePath))
{
conn.CreateTable<SignInInformation>();
var info = conn.Table<SignInInformation>().ToList();
userData.ItemsSource = info;
}
}
void DeleteButton_Clicked(object sender, EventArgs e)
{
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SP.LoginPage">
<ContentPage.ToolbarItems>
<ToolbarItem x:Name="DeleteButton"
Text="Delete"
Clicked="DeleteButton_Clicked">
</ToolbarItem>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<ListView x:Name="userData">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell Text="{Binding Id}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage.Content>
</ContentPage>