![](/img/trans.png)
[英]how to access files in xamarin.android. And also in Visual Studio Solution explorer where should i place the file in order to locate it in my code
[英]How do I merge my code behind file in the solution explorer?
我正在尝试为我的 blazor 应用程序创建一个代码隐藏文件(使用 .NET Core 3.1,Blazor 服务器端),同时它也显示在解决方案资源管理器中作为您可以单击打开的 razor 文件,然后看到razor.cs 文件中的树结构。
我设法使功能正常工作,但它仍然没有在解决方案资源管理器中正确显示。
据我所知,我所做的一切都是正确的,我什至尝试使用项目模板,但这也不起作用。 无论我尝试什么,它们总是显示为单独的文件。
文件名相同,除了扩展名,类继承自ComponentBase,我尝试在文件FetchData或FetchDataBase中调用该类,都不起作用。
我的类文件被称为:'FetchData.razor.cs' 我的剃刀文件被称为'FetchData.razor'
我错过了什么吗? 我使用的是 VS2019 V16.5.2,我需要使用预览版吗?
代码片段: 类:
public partial class FetchDataBase : ComponentBase
{
[Inject]
private CoordinatesService CoordinatesService { get; set; }
protected IEnumerable<ICoordinate> coordinates;
protected override async Task OnInitializedAsync()
{
coordinates = await CoordinatesService.GetCoordinates();
}
}
剃须刀页面:
@page "/fetchdata"
@inherits FetchDataBase
<h1>Coordinates</h1>
<p>This component demonstrates fetching data from a service.</p>
@if (coordinates == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Test</th>
</tr>
</thead>
<tbody>
@foreach (var coordinate in coordinates)
{
<tr>
<td>@coordinate.Test</td>
</tr>
}
</tbody>
</table>
}
解决方案资源管理器的图像:
谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.