내가 좋아하는 숙박 시설에 내 뷰 모델에 연결된 내 StackLayout. 이에 바인딩하여 내 StackLyout 뷰 모델.
때 나는 버튼을 클릭 레이아웃이어야 만들어 보이지 않습니다.
을 때 저는 이렇게 아래와 같은 코드,내 프로그램으로 NulReferenceObject:객체 참조 설정하지 않는 인스턴스의 개체입니다. 이 StackLayout 는 이야기에 대해서 첫 번째 아래 코드.
<FlexLayout>
<StackLayout BindableLayout.ItemTemplate="{Binding CreateQuizPageQuizNameSL}"> // This StackLayout should be bind to the ViewModel
<Label Text="Create New Quiz" />
<StackLayout >
<Entry Text="{Binding QuizNameInput}" Placeholder="Enter quiz name"/>
</StackLayout>
</StackLayout>
<Button Command="{Binding SubmitCreateQuizCommand}" Text="Create my quiz now!"></Button>
</FlexLayout>
뷰 모델
internal class CreateQuizPageViewModel
{
// Quiz Name Input
public String QuizNameInput { get; set; }
// Command submit creating a quiz
public Command SubmitCreateQuizCommand { get; set; }
public StackLayout CreateQuizPageQuizNameSL { get; set; } = new StackLayout();
public CreateQuizPageViewModel()
{
// Declaring a new command, giving the OnSubmitCreateNewQuizClick to the delegate
SubmitCreateQuizCommand = new Command(OnSubmitCreateNewQuizClick);
}
// When a user submit the creation of new quiz
public void OnSubmitCreateNewQuizClick()
{
CreateQuizPageQuizNameSL.IsVisible = false;
}
}