0
votes

i am a newbie of xamarin. i have a question.

i am implementing a test app using xamarin forms. this app has some screens.

important point is that all screens has common UI.

for example,

all screens has a circle button on the top-right, top-left corner.

so i tried to use inheritance (reference : https://forums.xamarin.com/discussion/87408/derived-pages-generate-incorrect-code)


case 1.

Base.cs(has circle view)

|

derived1.cs + derived1.xaml - derived2.cs + derived2.xaml

case 1 has a error. InitializeComponent() in derived1.cs(or derived2.cs)

"The name 'InitializeComponent' does not exist in the current context"


case 2.

Base.cs + Base.xaml(has circle view)

|

derived1.cs + derived1.xaml - derived2.cs + derived2.xaml

case 2 has a error. InitializeComponent() in derived1.cs(or derived2.cs)

"'Base.InitializeComponent()' is inaccessible due to its protection level"


i want to implement common UI. how do i do?

1

1 Answers

0
votes

if you want to have a reusable UI use ContentView

https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.contentview?view=xamarin-forms

you can place multiple views on the same content page.

Hope this helps.