【发布时间】:2018-11-26 12:27:32
【问题描述】:
类别 XAML 代码段 -->
<StackLayout Grid.Column ="1" Grid.Row ="0" Orientation ="Vertical" BackgroundColor ="White" Padding ="10" HorizontalOptions ="FillAndExpand">
<Image Source ="banking.png" HorizontalOptions ="CenterAndExpand "/>
<Label Text ="Finance" FontSize ="Small " HorizontalOptions ="FillAndExpand" HorizontalTextAlignment ="Center"/>
</StackLayout>
<StackLayout Grid.Column ="2" Grid.Row ="0" Orientation ="Vertical" BackgroundColor ="White" Padding ="10" HorizontalOptions ="FillAndExpand">
<Image Source ="legal.png" HorizontalOptions ="CenterAndExpand "/>
<Label Text ="Legal" FontSize ="Small " HorizontalOptions ="FillAndExpand" HorizontalTextAlignment ="Center"/>
</StackLayout>
请帮忙。我需要的是能够将一个名为“CategoryName”的变量传递给我的 SearchAPI 控制器并检索具有该类别的所有数据库条目。我的 SearchAPIController 如下所示
[Route("api/Oppotunities/Search/{keyword}")]
[ResponseType(typeof(List<Oppotunity>))]
public async Task<IHttpActionResult> GetOppotunitiesByKeyword(string keyword)
{
List<Oppotunity> oppotunities = db.Oppotunities
.Where(oppotunity => oppotunity.Title.Contains(keyword)
|| oppotunity.Description.Contains(keyword)
|| oppotunity.Category.Contains(keyword)
|| oppotunity.Organisation.Contains(keyword)).ToList();
if (oppotunities == null)
{
return NotFound();
}
return Ok(oppotunities);
}
【问题讨论】:
-
您可以使用
button代替Image。 Button 定义了当用户用手指或鼠标指针点击 Button 时触发的 Clicked 事件。此外,一个按钮显示文本和图像。
标签: c# xaml xamarin xamarin.forms