음, 기본적으로, 당신은 모두 (이 Xamarin.Forms에 안드로이드에 Drawer
및 Master
를 불렀다)와 내용 없음 (이 Xamarin.Forms에 Detail
를 불렀다) "보기 슬라이드"인 MasterDetailPage 있습니다. 이러한 각각의보기는 Xamarin의 페이지입니다.
당신은 그냥이 같은 페이지에 두 예절 (마스터 및 세부) 설정하여 MasterDetailPage을 만들 수 있습니다
// MainPage here is the Propriety of the App class that controls the current displayed page
MainPage = new MasterDetailPage
{
Master = new ContentPage { Content = new StackLayout { Children = { new Label { Text = "This is the Drawer Page!" } } } },
Detail = new ContentPage { Content = new StackLayout { Children = { new Label { Text = "This is the Detail Page!" } } } }
};
앱 클래스에이를 추가하고 "This is the Drawer Page!"
을 말한다 서랍을해야합니다 세부 정보 페이지는 "This is the Detail Page!"
입니다.
이제 클래스에서 그 ContentPages를 분리하는 경우,이 같은 것입니다 :
public class MasterPage : ContentPage
{
public MasterPage()
{
Content = new StackLayout
{
Children =
{
new Label { Text = "This is the Master page!" }
}
}
}
}
public class DetailPage : ContentPage
{
public DetailPage()
{
Content = new StackLayout
{
Children =
{
new Label { Text = "This is the Detail page!" }
}
}
}
}
// And in the App constructor
MainPage = new MasterDetailPage
{
Master = new MasterPage(),
Detail = new DetailPage()
};
그리고 그것 뿐이다 ... 당신은 이것에 대해 더 이상 질문 :
을 물어 주시기 바랍니다가있는 경우 코멘트
이 코드는 응용 프로그램 클래스에서 사용하기위한 것입니다 후
편집, 다른 클래스는 MainPage
속성이 없습니다.
App.Current.MainPage = new MainPage
{
Master = MasterPage(),
Detail = DetailPage()
};
을 : 당신이 당신의 MainPage 클래스 방금 대신 탐색으로 밀어의, 로그인 후,
MasterDetailPage
에서
MainPage
(
public class MainPage : MasterDetailPage
)를 확장 할 수있는
MasterDetailPage
싶은 경우
는, 호출하여 응용 프로그램의 MainPage
당신의 MainPage에 설정
아주 좋은 간단한 공식 가이드가 있습니다. 확인 했니? https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/navigation/master-detail-page/ – EvZ
@EvZ MainPageCS 페이지를 만들려고 할 때 "Master = MasterPage;" 줄의 이름은 Master가 현재 컨텍스트에 존재하지 않는다고 말합니다. –
@Jacob 자신 만의 MasterPage를 만들고 MasterPageItem에 세부 정보 페이지를 넣어야합니다. –