我仍在学习 Xamarin Forms 和 C#。所以在我的 MainPage.xaml 我有这个:
<StackLayout>
<Button Text="bttn1" Clicked="Button_Clicked"/>
<Button Text="bttn2" Clicked="Button_Clicked_1"/>
<ContentView x:Name="DisplayCustomContentView">
</ContentView>
</StackLayout>
和两个内容视图:
视图 1:
public class View1 : ContentView
{
public View1 ()
{
Content = new StackLayout {
Children = {
new Label { Text = "View 1" },
new Entry {Placeholder = "entry1 View 1"},
new Entry {Placeholder = "entry2 View 1"}
}
};
}
}
视图2:
public class View2 : ContentView
{
public View2 ()
{
Content = new StackLayout {
Children = {
new Label { Text = "View 2" },
new Entry {Placeholder = "entry2 View 1"},
new Entry {Placeholder = "entry2 View 2"}
}
};
}
}
所以当我点击按钮时,我想在视图之间交换。我试过这个:
private void Button_Clicked(object sender, EventArgs e)
{
DisplayCustomContentView = new View1();
}
我如何从Entry字段中获取值?
我很确定我做的方法不对。我可以使用我能得到的所有帮助!
慕姐8265434
慕工程0101907
相关分类