在 UWP 中,我享受使用 SQLite.Net-PCL 的好处,创建要在应用程序中使用的类作为 ObservableCollections 以绑定到 GridView。在包含 SQLiteNetExtensions 以构建带有外键的数据库后,我注意到在 SQLite Maestro 中查看数据库时并未真正创建外键。而是创建索引。 如果 SQLiteNetExtensions 并没有真正创建外键,那么使用它有什么好处?
使用 LAMDA 表达式或 LINQ 进行查询时,可能不需要外键(稍后在创建数据库后的应用程序中)。 如果我在不使用 SQLite.Net-PCL 的情况下执行查询以创建带有外键的表,我是否仍然可以使用 SQLite.Net-PCL 继续将 ObservableCollections 绑定到 GridViews?
示例数据库:
[Table("Book")]
public class Book
{
[PrimaryKey, AutoIncrement, Column("ID")]
public int ID { get; set; }
[Column("Name")]
public string Name { get; set; }
[ManyToMany]
public List<Checkout> Checkout { get; set; }
}
[Table("School")]
public class School
{
[PrimaryKey, AutoIncrement, Column("ID")]
public int ID { get; set; }
[Column("Name")]
public string …
Run Code Online (Sandbox Code Playgroud) 我有一个带有 2 个按钮的自定义视图 - 一个在左侧,一个在右侧。
我想要一个可绑定的属性来指示每个按钮将调用哪个函数,但我想要调用的函数是在原始内容页面中,而不是在自定义控件中。
我知道您不能将 void 作为可绑定属性,所以我不确定如何实现这一点。
这是我的自定义控件 xaml:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="EngineerApp.HeaderBar" HeightRequest="50">
<BoxView x:Name="banner" BackgroundColor="#edeff2"
RelativeLayout.WidthConstraint="{ ConstraintExpression
Type=RelativeToParent,
Property=Width,
Factor=1 }"
RelativeLayout.HeightConstraint="{ ConstraintExpression
Type=RelativeToParent,
Property=Height,
Factor=1 }">
</BoxView>
<Button
Text="Left"
x:Name="btnLeft"
Style="{StaticResource headerBarButton}"
RelativeLayout.WidthConstraint="{ ConstraintExpression
Type=RelativeToView,
ElementName=banner,
Property=Width,
Factor=0.5 }"
RelativeLayout.HeightConstraint="{ ConstraintExpression
Type=RelativeToView,
ElementName=banner,
Property=Height,
Factor=1 }"
>
</Button>
<Button
Text="Right"
Style="{StaticResource headerBarButton}"
RelativeLayout.XConstraint="{ ConstraintExpression
Type=RelativeToView,
ElementName=banner,
Property=Width,
Factor=0.5,
Constant=1
}"
RelativeLayout.WidthConstraint="{ ConstraintExpression
Type=RelativeToView,
ElementName=banner,
Property=Width,
Factor=0.5 }"
RelativeLayout.HeightConstraint="{ ConstraintExpression
Type=RelativeToView,
ElementName=banner,
Property=Height, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的 Xamarin 表单应用程序中使用 HttpUtility。我有一个 Pcl 项目。这不可能吗?我尝试添加 system.web 命名空间,但没有成功。请协助。我怎样才能让它发挥作用。
string postString = String.Format("username={0}&password={1}&grant_type=password", HttpUtility.HtmlEncode(username), HttpUtility.HtmlEncode(password));
Run Code Online (Sandbox Code Playgroud)