我在我的UWP应用程序中有ListView,并希望它设置100%的显示宽度.
这是我在xaml文件中的代码
<Page
x:Class="TestApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView x:Name="PostList" ItemsSource="{Binding PostsList}" HorizontalAlignment="Left" Height="720" VerticalAlignment="Top" Width="1280">
<ListView.ItemTemplate>
<DataTemplate>
<Grid x:Name="GridInf" Height="204" BorderBrush="#FFFBF8F8" BorderThickness="0,0,1,1">
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
Run Code Online (Sandbox Code Playgroud)
我试着这样做 Width="100%"
但它不起作用?
我怎么能做到的?
我使用 WebAPI2 编写 REST 服务
我需要将书添加到数据库。
我有这个代码模型:
public class Book
{
public int Id { get; set; }
public string Name { get; set; }
public string Author { get; set; }
public int Year { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
和控制器:
[HttpPost]
public void CreateBook([FromBody]Book book)
{
db.Books.Add(book);
db.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)
我尝试从邮递员发送 POST 请求
但我有这个错误
"Message": "此资源不支持请求实体的媒体类型 'multipart/form-data'。", "ExceptionMessage": "没有 MediaTypeFormatter 可用于从具有媒体类型的内容中读取类型为 'Book' 的对象'多部分/表单数据'。”
我怎么能应付呢?