我正在使用xamarin開發一個android應用程序。我做了標籤頁。對於第二頁,我想從我的android相機中顯示camerastream。爲此,一些示例代碼表示我需要在應用的android部分中使用textureView,但是該紋理視圖需要放在第二頁上。每當我嘗試訪問該頁面內的Stacklayout時,出現以下錯誤:由於其保護級別,'Page1.camera'無法訪問。 使用x:FieldModifier =「public」該堆棧佈局內部也不起作用。從android項目中的xamarin.forms到達一個頁面
這裏是我的代碼的結構,使之更加明確
在這裏,我做了標籤頁:
MainPage = new TabbedPage
{
Children = {
new MainPage(),
new Page1(),
new Page2()
}
};
內部的第一頁,我有這樣的:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App4.Page1"
Title="Licht">
<StackLayout x:Name="camera" x:FieldModifier="public" Orientation="Vertical">
</StackLayout>
</ContentPage>
而且裏面MainActivity.cs我有這個地方我必須訪問相機。
_textureView = new TextureView(Page1.camera);
這是我的應用程序 And this is the structure of my app
我沒有想到使用渲染頁面。謝謝你的幫助! –