[英]How can I call a xaml inside another
I have a screen as main and a secondary with two buttons(ImageButton) and I would like to call the screen with the buttons(ImageButton) inside the main.我有一个主屏幕和一个带有两个按钮(ImageButton)的辅助屏幕,我想用主屏幕内的按钮(ImageButton)调用屏幕。 As there were several screens with the same buttons(ImageButton) to decrease the amount of image in each screen I want to call this xaml with buttons(ImageButton) inside the other screens to simplify the amount of image.
由于有几个屏幕具有相同的按钮(ImageButton)来减少每个屏幕中的图像数量,我想在其他屏幕内使用按钮(ImageButton)调用此 xaml 以简化图像数量。 I tried this way and it did not work.
我试过这种方式,但没有奏效。
Main主要的
<StackLayout>
<!-- Place new controls here -->
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
<ContentPage.Content>
<local:tela></local:tela>
</ContentPage.Content>
Tela特拉
<ContentPage.Content>
<StackLayout HorizontalOptions="EndAndExpand" Orientation="Horizontal">
<Button Text="Abrir"></Button>
<Button Text="Fechar"></Button>
</StackLayout>
</ContentPage.Content>
Your file Tela should be ContentView
instead of ContentPage
.您的文件Tela应该是
ContentView
而不是ContentPage
。
<ContentPage.Content>
<StackLayout>
<StackLayout>
<!-- Place new controls here -->
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
<local:tela></local:tela>
</StackLayout>
</ContentPage.Content>
Your ContentView
你的内容
ContentView
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App1.Tela">
<StackLayout HorizontalOptions="EndAndExpand" Orientation="Horizontal">
<Button Text="Abrir"></Button>
<Button Text="Fechar"></Button>
</StackLayout>
</ContentView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.