英文:
Creating MAUI wizard control
问题
我正在创建一个 MAUI 中的向导控件。其中一个屏幕如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:helpers="clr-namespace:TimeApp.Helpers"
x:Class="TimeApp.Controls.Wizard.Steps.SetupWizardWelcomeView">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<VerticalStackLayout VerticalOptions="Start">
<Label
Text="¡ Bienvenido a su enrolamiento !"
HorizontalOptions="Center" />
</VerticalStackLayout>
<StackLayout Padding="0, 20, 0, 20" VerticalOptions="CenterAndExpand">
<Label
Text="Por medio de este asistente, podrá darse de alta en el sistema de control de asistencia de su empresa" />
</StackLayout>
<VerticalStackLayout VerticalOptions="End">
<Grid ColumnDefinitions="*, *" BackgroundColor="red">
<HorizontalStackLayout HorizontalOptions="FillAndExpand">
<Button Margin="10, 0, 10, 0" Text="Anterior" Grid.Column="0" HorizontalOptions="Start">
<Button.ImageSource>
<FontImageSource
FontFamily="FontAwesomeSolid"
Glyph="{x:Static helpers:FontAwesomeIcons.Previous}"
Color="DodgerBlue"
Size="24"/>
</Button.ImageSource>
</Button>
<Button Margin="10, 0, 10, 0" Grid.Column="1" HorizontalOptions="End">
<Button.ImageSource>
<FontImageSource
FontFamily="FontAwesomeSolid"
Glyph="{x:Static helpers:FontAwesomeIcons.Next}"
Color="DodgerBlue"
Size="24"/>
</Button.ImageSource>
<Button.Text>Siguente</Button.Text>
</Button>
</HorizontalStackLayout>
</Grid>
</VerticalStackLayout>
</StackLayout>
</ContentView>
首先,我需要将按钮放在页面底部,其次,将 FontAwesomeIcons.Next
图标放在按钮标签的右侧。如何实现呢?我已经花了好几个小时尝试,但没有成功。
英文:
I am creating a wizard control in MAUI. On of the screens is this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:helpers="clr-namespace:TimeApp.Helpers"
x:Class="TimeApp.Controls.Wizard.Steps.SetupWizardWelcomeView">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<VerticalStackLayout VerticalOptions="Start">
<Label
Text="¡ Bienvenido a su enrolamiento !"
HorizontalOptions="Center" />
</VerticalStackLayout>
<StackLayout Padding="0, 20, 0, 20" VerticalOptions="CenterAndExpand">
<Label
Text="Por medio de este asistente, podrá darse de alta en el sistema de control de asistencia de su empresa" />
</StackLayout>
<VerticalStackLayout VerticalOptions="End">
<Grid ColumnDefinitions="*, *" BackgroundColor="red">
<HorizontalStackLayout HorizontalOptions="FillAndExpand">
<Button Margin="10, 0, 10, 0" Text="Anterior" Grid.Column="0" HorizontalOptions="Start">
<Button.ImageSource>
<FontImageSource
FontFamily="FontAwesomeSolid"
Glyph="{x:Static helpers:FontAwesomeIcons.Previous}"
Color="DodgerBlue"
Size="24"/>
</Button.ImageSource>
</Button>
<Button Margin="10, 0, 10, 0" Grid.Column="1" HorizontalOptions="End">
<Button.ImageSource>
<FontImageSource
FontFamily="FontAwesomeSolid"
Glyph="{x:Static helpers:FontAwesomeIcons.Next}"
Color="DodgerBlue"
Size="24"/>
</Button.ImageSource>
<Button.Text>Siguente</Button.Text>
</Button>
</HorizontalStackLayout>
</Grid>
</VerticalStackLayout>
</StackLayout>
</ContentView>
I am not getting the page to look how I need.
First, I need the buttons to be placed at the bottom of the page and second, to place the FontAwesomeIcons.Next
icon to the right of the button label.
How can I do that? I have already spent several hours trying to do this but no avail.
答案1
得分: 0
Sure, here's the translated content:
将FontAwesomeIcons.Next图标放置在按钮标签的右侧。
要实现这一点,您可以使用ContentLayout
属性,该属性定义了控制按钮图像位置以及按钮图像和文本之间间距的对象。
所以,如果您想将图标放在文本的右侧,请尝试以下操作:
<Button WidthRequest="200" Margin="10, 0, 10, 0" Text="Anterior" ContentLayout="Right,1">
其中的 "1" 表示文本和图像之间的间距。
要将按钮放置在底部,正如@Jason所说,使用网格可以实现这一点,尽管您使用了自定义控件。解决方案类似于以下内容:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
...>
<Grid RowDefinitions="*,Auto">
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
......
</VerticalStackLayout>
<local:CustomControl Grid.Row="1"/> // 您的自定义控件/ContentView
</Grid>
</ContentPage>
希望能够起作用。
英文:
> to place the FontAwesomeIcons.Next icon to the right of the button label.
To achieve this, you may use ContentLayout
property which defines the object that controls the position of the button image and the spacing between the button's image and text.
So you want to place the icon the right of the text, try the following:
<Button WidthRequest="200" Margin="10, 0, 10, 0" Text="Anterior" ContentLayout="Right,1">
The "1" stands for the spacing between the text and the image.
To place the button at the bottom, just as @Jason said, using a grid can achieve this, though you use a custom control. The solution is the similar.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
...
>
<Grid RowDefinitions="*,Auto">
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
......
</VerticalStackLayout>
<local:CustomControl Grid.Row="1"/> // your custom control/ContentView
</Grid>
</ContentPage>
Hope it works
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论