![](/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.