英文:
Flex Grow on .NETMAUI
问题
I need a grow here. (我需要在这里添加 Grow。)
英文:
Im trying to add a Grow 1 on my .NET MAUI .cs file, can someone please steer me in the right direction, here is the code for the whole file..
Any help would be greatly appreciated! Thanks in advance ![]()
using Microsoft.Maui.Layouts;
using Microsoft.Maui.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PagesDemo
{
public class FlexDemo : ContentPage
{
public FlexDemo()
{
Content = new FlexLayout
{
Direction = FlexDirection.Column,
Children = {
new Label
{
Text = "HEADER",
FontSize = 18,
BackgroundColor = Colors.Aqua,
HorizontalTextAlignment = TextAlignment.Center,
},
new FlexLayout
{
// I need a grow here
}
}
};
}
}
}
答案1
得分: 1
new Label().Grow(1f);
var layout2 = new FlexLayout
{
// contents
};
Content = new FlexLayout
{
...
Children = {
...,
layout2
}
};
layout2.Grow(1f);
英文:
In FlexLayout extensions / Grow is this code snippet:
new Label().Grow(1f);
In your code:
- above
Content = ..., make a local variable holding what you want to grow. - Then add that variable to children.
- Finally set Grow afterwards:
var layout2 = new FlexLayout
{
// contents
};
Content = new FlexLayout
{
...
Children = {
...,
layout2
};
layout2.Grow(1f);
NOTE: It might be possible to move layout2.Grow.. line before Content = .... I haven't tried it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论